0

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.

Anish Kumar
  • 1,465
  • 16
  • 20

1 Answers1

0

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!

Community
  • 1
  • 1
Anish Kumar
  • 1,465
  • 16
  • 20