使用签名的URL从iOS超时发布到S3 [英] Timeout POSTING to S3 from iOS using signed URLS

查看:160
本文介绍了使用签名的URL从iOS超时发布到S3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的服务器正在生成用于签名上传到S3的信息.当我将该信息传递给iOS时,它适用于小文件.有时,它也适用于较大的产品,但通常会超时.我目前正在通过WIFI在iOS 7上进行测试.通常,在大约35 MB的文件上大约有60%的时间后会超时,但有时它会完成,有时会更快地超时.

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.

我的服务器生成以下信息,这些信息作为表单的一部分传递给POST. (我也尝试将其作为参数使用,结果相似):

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
  • 内容类型
  • acl(设为私有)
  • 政策
  • 签名
  • success_action_redirect

以及网址.

这是我生成上传的代码:

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
               }];

这会产生以下错误:

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."}

更新:

我应该提到几个类似的问题.很多人在Heroku超时方面遇到麻烦,但是我直接上传到S3.

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.

此人上传到自己的服务器上似乎也有同样的问题: -使用AFNetworking在iOS上上传大文件-错误请求超时

This person seems to have the same problem uploading to his own server: - Uploading large files on iOS with AFNetworking - error Request Timeout

这个问题看起来像使用AWS库的类似问题,但是它们不提供任何代码:

This question looks like a similar problem using the AWS library, but they don't provide any code:

通过AFNetworking上载到Amazon-S3

这个问题似乎有关,但是从源头来看,发布文件时似乎考虑了长度:

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

推荐答案

在视频文件(mp4文件)上也发生了这种情况. 问题是我的视频文件很小(最大2-5MB).

It happens to me on video files as well, mp4 files. The thing is that my video files are small (2-5MB max).

我正在使用AWSiOSSD 2.5.2,iPhone 6s 7和7plus以及10+版本(包括最新版本).

I'm using AWSiOSSD 2.5.2, iPhones 6s 7 and 7plus with versions 10+ (including the latest ver).

到目前为止,尚无解决方法,包括6个月前在此线程上发布的otusweb答案.

No workarounds worked so far, including otusweb answer posted 6 months ago on this thread.

这篇关于使用签名的URL从iOS超时发布到S3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆