Oleg Gordiichuk
Oleg Gordiichuk

Reputation: 15512

AWS iOS SDK v2 Files Upload to S3 issue

I am trying to upload images to the S3, and for files that are less than 2 mb, it is ok, but for more than 2 mb, server return Code=-1001 "The request timed out.". Could someone explain how it is possible to handle this problem?

Code example below:

AWSS3 *s3 = [[AWSS3 alloc] initWithConfiguration:configuration];
AWSS3PutObjectRequest *logFile = [AWSS3PutObjectRequest new];
logFile.bucket = bucket;
logFile.key = path;
logFile.contentType = [self contentTypeForImageData:self.userPicture];
logFile.body = self.userPicture;
logFile.contentLength =  [NSNumber numberWithInteger:[self.userPicture length]];
[[s3 putObject:logFile] continueWithBlock:^id(BFTask *task) {
    NSLog(@"Amazon error : %@", [task error]);
   return nil;
}];

Upvotes: 2

Views: 906

Answers (1)

Yosuke
Yosuke

Reputation: 3759

When using initWithConfiguration:, you must manually retain a strong reference to an instance of AWSS3. One way to accomplish this is to make it a property. Using defaultS3 eliminates the need for this since the AWSS3 class retains the strong reference to the default service client for you.

Hope this helps,

Upvotes: 1

Related Questions