简体   繁体   中英

AWS S3 uploading not working

I'm using the following to upload images to S3. Weirdly, it doesn't even enter the Block. So, no error, no success indication...it simply doesn't return anything at all. I haven't seen this happened before.

    AWSS3TransferManagerUploadRequest *amazonUploadRequest = [AWSS3TransferManagerUploadRequest new];
    amazonUploadRequest.bucket = AWS_PICTURE_BUCKET;
    amazonUploadRequest.body = fileUrl;
    amazonUploadRequest.key = key;
    amazonUploadRequest.contentType = @"image/jpeg";

    AWSS3TransferManager *transferManager = [AWSS3TransferManager defaultS3TransferManager];
    [[transferManager upload:amazonUploadRequest] continueWithBlock:^id _Nullable(AWSTask * _Nonnull task) {
//Never reaches here.
        if (task.error == nil) {
            completionBlock();
        } else {
            errorBlock(task.error);
        }
        return nil;
    }];

Anyone seen this issue ever? I have used this in the past to upload 1 or 2 images or even 50 images in loop. I am trying right now with 100 right now and it doesn't even execute once.

Found it!

So I was using dispatch_semaphore_t asynchronously for each upload and it turns out GCD has a 64 thread limit and I was hitting that with 100 + uploads. This was making all the uploads wait (DISPATCH_TIME_FOREVER) and hence it seemed like AWS method wasn't responding.

I fixed it by adjusting dispatch_semaphore_t and getting rid of my asynchronous block for individual upload. If you find yourself in this situation, hit the pause button and look for the number of threads running at a time.

Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM