Download to Amazon-S3 via AFNetworking

I find it difficult to upload files to S3 through AFNetworking. When I try to download, I get callbacks indicating that a small percentage of the file has been downloaded, and then the callbacks stop and after one or two minutes I get a timeout message.

I use AFAmazonS3Client , but it seems like a fairly simple subclass of AFHTTPClient, so it seems unlikely that the problem is missing there. Since I'm new to AFNetworking and S3, I am sure the problem is to print this message :)

I downloaded the AWS-IOS SDK and was able to post the image from my sample code without any problems. Therefore, I do not consider it to be an incorrect configuration of my S3 account.

+3
source share
1 answer

After a battle with the same problem and a bit of research, I found a solution that seems to work well.

Download the Amazon AWS SDK for iOS and add it to your project:

http://aws.amazon.com/sdkforios/

Then run the load test with a custom class NSOperationas described here:

Using delegates, operations, and queues

A protocol AmazonServiceRequestDelegateis the key to getting progress updates, similar to what it does AFNetworking.

In particular, I need this method:

-(void)request:(AmazonServiceRequest *)request didSendData:(NSInteger)bytesWritten
    totalBytesWritten:(NSInteger)totalBytesWritten
    totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite;
0
source

All Articles