My server is generating info for a signed upload to S3. When I pass that info on to iOS, it works for small files. Sometimes it works for bigger ones as well, but it often times out. I am currently testing on iOS 7 over WIFI. It's typical for it to time out after about 60% on an approximately 35 MB file, but sometimes it completes and sometimes it times out sooner.
My server generates the following info, which I pass on as form parts to my POST. (I also tried it as parameters with similar results):
- AWSAccessKeyId
 - Content-Type
 - acl (set to private)
 - bucket
 - key
 - policy
 - signature
 - success_action_redirect
 
as well as a URL.
Here is my code that generates the upload:
AFHTTPRequestOperation *op = [manager POST:url
                                parameters:nil
                 constructingBodyWithBlock:^(id<AFMultipartFormData> formData)
          {
              if( throttle )
                  [formData throttleBandwidthWithPacketSize:kAFUploadStream3GSuggestedPacketSize delay:kAFUploadStream3GSuggestedDelay];
              for( id key in parameters ) {
                  NSString *val = parameters[key];                      
                  [formData appendPartWithFormData:[val dataUsingEncoding:NSUTF8StringEncoding] name:key];
              }
              NSError *error;
              if( ![formData appendPartWithFileURL:videoUrl name:@"file" fileName:@"movie.mov" mimeType:@"video/quicktime" error:&error] ) {
                  // handle the error
              }
          } success:^(AFHTTPRequestOperation *operation, id responseObject) {
              //success
          }
               failure:^(AFHTTPRequestOperation *operation, NSError *error) {
                   if( error.code == -1021 && !throttle ) {
                       //try again with throttle:
                   }
                   NSLog(@"Error: %@", error);
                   // handle error
               }];
This generates the following error:
Error: Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo=0x1aa15130 {NSErrorFailingURLStringKey=XXX, NSErrorFailingURLKey=XXX, NSLocalizedDescription=The request timed out., NSUnderlyingError=0x1ab94290 "The request timed out."}
UPDATE:
There are several similar questions on SO I should mention. A lot of people have trouble with Heroku timeouts, but I'm uploading directly to S3.
This person seems to have the same problem uploading to his own server: - Uploading large files on iOS with AFNetworking - error Request Timeout
This question looks like a similar problem using the AWS library, but they don't provide any code:
Uploading to Amazon-S3 via AFNetworking
This issue seems related, but looking at the source, it seems that length is taken into account when posting a file:
https://github.com/AFNetworking/AFNetworking/issues/1510#issuecomment-29687300