针对iOS SDK v2的Amazon S3视频上传问题 [英] Amazon S3 video upload issue for the iOS SDK v2

查看:204
本文介绍了针对iOS SDK v2的Amazon S3视频上传问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的开发人员,我有问题,与亚马逊S3视频上传。

我正在使用iOS SDK V2安排iOS客户端和亚马逊之间的交互。我已经阅读了所有的文档和调查由亚马逊的开发者提供的手册,并且发生了一些没有记录的问题。

我将开始从开始。

1)身份验证,我正在使用STS方法为Amazon s3请求验证用户身份。
这个steP不是因为我使用这个认证配置来上传图片,而且一切正常。



2)


AWSS3TransferManager


上传示例代码:

  AWSS3PutObjectRequest * logFile = [AWSS3PutObjectRequest新]; 
logFile.bucket = uploadTokenData_.bucket;
logFile.key = key;
logFile.contentType = contentType;
logFile.body = data_;
logFile.contentLength = [NSNumber numberWithInteger:[data_length]];

AWSS3 * S3 = [[AWSS3 alloc] initWithConfiguration:[AWSCredentialsProvider runServiceWithStsCredential]];

AWSS3TransferManager * transferManager = [[AWSS3TransferManager alloc] initWithS3:S3];

[[transferManager.s3 putObject:logFile] continueWithBlock:^ id(BFTask * task)
{

NSLog(@Error:%@,task 。错误);
if(task.error == nil)
{
NSLog(@Uploadet);


code
$ b $ 3





$ b $
$ b 1)-1001:几乎立即的错误响应为s3文件上传更加准确我将为您提供来自亚马逊响应的调试线。


AWSiOSSDKv2 [Debug] AWSSignature.m line:642 |
- [AWSS3ChunkedEncodingInputStream nextChunk] | stream read:32677,chunk size:32768

Domain = NSURLErrorDomain Code = -1001请求超时。



$ b $ 2)它堆叠在文件的随机块上,并停止上传到服务器,并且写入网络连接丢失,但是Internet连接已经启动。


错误域= NSURLErrorDomain代码= -1005网络连接是
丢失。


4)结论



不过,这种方法不时将视频文件上传到亚马逊,奇怪的。例如,从早上我上传视频文件为77 MB,现在每次我收到。


域= NSURLErrorDomain代码= -1001

如果有人知道甚至有一些想法如何解决这个问题,请给我一些建议。

感谢您的宝贵时间!

解决方案

您实例化 AWSS3 AWSS3TransferManager 的实例(而不是使用 defaultS3 defaultS3TransferManager ),则需要手动保留对客户端对象的强引用。在你的代码片段中,你的传输管理器对象可以在 putObject:完成之前释放,S3客户端也可以随后被释放。



您可以在 defaultServiceManager 上使用 -setService:forKey:> AWSServiceManager 让服务经理为您管理强大的引用。


Dear developers i have issue that is connected with Amazon S3 video upload.

I am using iOS SDK V2 for arrange interaction between iOS Client and Amazon. I already read all documentation and investigate manuals that were provider by the developers from the Amazon and some issues occurs that are not documented.

I will start explaining problem from very beginning.

1) Authentication, i am using STS approach to authenticate users for the Amazon s3 request. This steP is not a point due to that i am using this authentication configuration to upload images as well and everything work perfectly.

2) For the uploading of the Video file i am using:

AWSS3TransferManager

Sample code of the uploading:

AWSS3PutObjectRequest *logFile = [AWSS3PutObjectRequest new];
  logFile.bucket = uploadTokenData_.bucket;
  logFile.key = key;
  logFile.contentType = contentType;
  logFile.body = data_;
  logFile.contentLength = [NSNumber numberWithInteger:[data_ length]];

AWSS3 *S3 = [[AWSS3 alloc] initWithConfiguration:[AWSCredentialsProvider runServiceWithStsCredential]];

AWSS3TransferManager *transferManager = [[AWSS3TransferManager alloc] initWithS3:S3];

[[transferManager.s3 putObject:logFile] continueWithBlock:^id(BFTask *task)
{

  NSLog(@"Error : %@", task.error);
  if (task.error == nil)
  {
    NSLog(@"Uploadet");
  }
}

3) Problems that occure.

1) -1001: Almost immediate error response for the s3 file uploading to be more precise i will provide you debug line of the response from Amazon.

AWSiOSSDKv2 [Debug] AWSSignature.m line:642 | -[AWSS3ChunkedEncodingInputStream nextChunk] | stream read: 32677, chunk size: 32768

Domain=NSURLErrorDomain Code=-1001 "The request timed out."

2) It stack on random chunk of the file and stop uploading it to the server.And write network connection is lost, but Internet connection is up.

Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost."

4) Conclusion

But nevertheless this approach upload video files to the Amazon from time to time and it is quite strange.For example from very morning i upload video file for 77 MB and now each time i receive.

Domain=NSURLErrorDomain Code=-1001

If someone know or even have some ideas how to solve this problem please give me some advise.

Thanks a lot for your time!

解决方案

When you instantiate instances of AWSS3 or AWSS3TransferManager (instead of using defaultS3 or defaultS3TransferManager), you need to manually retain strong references to the client objects. In your code snippet, your transfer manager object can be released before putObject: completes, and the S3 client can subsequently be released, too.

You can use -setService:forKey: on defaultServiceManager of AWSServiceManager to have the service manager manage the strong references for you.

这篇关于针对iOS SDK v2的Amazon S3视频上传问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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