3

I'm having difficulty uploading files to S3 via AFNetworking. When I attempt to upload, I get callbacks indicating a small percentage of the file is uploaded, then the callbacks cease, and one or two minutes later I get a timeout message.

I'm using AFAmazonS3Client but it seems like a pretty straight forward subclass of AFHTTPClient so it seems unlikely the problem lies there. Since I'm new to both AFNetworking and S3, I'm pretty sure the problem is typing this message :)

I've downloaded the AWS-IOS SDK and was able to post a picture from their sample code without a problem. So I don't think its a misconfiguration of my S3 account.

Martin
  • 1,570
  • 3
  • 19
  • 32
  • Heh, such is the unfortunate peril of early-stage open source. Sorry about that. I haven't run into anything like this particularly, at least recently. I'm looking to ship a project with this soon, so I'll definitely get to the bottom of this before that happens! – mattt May 10 '12 at 04:21
  • Wish I could add more to this, but I'm having the same problem! Might be time to dig into the code a bit more... – Aaron Vegh May 26 '12 at 02:25
  • I've been trying this with the boilerplate afnetworking upload code and I'm getting an error 400, and it seems to be that the file in the multipart upload is not being set exactly right – MonkeyBonkey May 28 '12 at 22:42
  • After considering other solutions, I'm back to this one. Has anyone found a way around this issue? – Aaron Vegh Oct 25 '12 at 02:38
  • I am having the same problem using AFNetworking directly: My server is generating an upload URL along with some parameters, which I pass to AFNetworking to make my POST. For small, and even medium sized files everything is fine. For larger files, it sometimes works, but usually does what you describe. I tried increasing the timeout, but that only makes the failure take longer. – Bjorn Roche Dec 09 '13 at 01:25

1 Answers1

0

After struggling a bit 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, implement the upload test with a custom NSOperation class as explained here:

Using delegates, operations, and queues

The AmazonServiceRequestDelegate protocol is the key to get progress updates, in a similar fashion to what AFNetworking does.

In particular, this method is what I needed:

-(void)request:(AmazonServiceRequest *)request didSendData:(NSInteger)bytesWritten
    totalBytesWritten:(NSInteger)totalBytesWritten
    totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite;
Community
  • 1
  • 1
bizz84
  • 1,964
  • 21
  • 34
  • This library doesn't support OSX, so I'm hoping to resolve this issue with AFAmazonS3Client that I am also experiencing. – Alex Nauda Apr 13 '13 at 17:18