AFNetworking / AFAmazonS3Client亚马逊文件上传

时间:2013-03-07 18:42:36

标签: iphone ios afnetworking

我尝试使用AFNetworking / AFAmazonS3Client将文件上传到Amazon时出现以下错误

s3Client = [[AFAmazonS3Client alloc] initWithAccessKeyID:@"mykey" secret:@"mysecretkey"];
s3Client.bucket = @"media.mysite.com";

[s3Client postObjectWithFile:video.assetPath destinationPath:@"/media/videos/" parameters:nil progress:

 ^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite){

     DLog(@"%f%% Uploaded", (totalBytesWritten / (totalBytesExpectedToWrite * 1.0f) * 100));
 }

                     success:^(id responseobject){

                         DLog(@"Success");
                         [self deleteAsset:video];

                     }failure:^(NSError* error){

                          DLog(@"Failed %@", error);
                         [self updateVideoAsset:video.assetID key:@"uploadStatus" value:[NSNumber numberWithInt:ESUploadNotStarted]];
                     }];

此服务器的证书无效。您可能连接到假装是“media.myserver.com.s3.amazonaws.com”的服务器,这可能会使您的机密信息面临风险

如何解决这个问题

由于 Tonku

2 个答案:

答案 0 :(得分:0)

AWS SDK for iOS(旧版本)中似乎存在一些可能导致此问题的问题:https://forums.aws.amazon.com/message.jspa?messageID=248288

答案 1 :(得分:0)

如果有其他人偶然发现:使用没有句点的广告素材名称(例如media-mysite-com)。这样,亚马逊的通配符SSL证书仍然适用,您将避免错误。

参见例如How to Configure SSL for Amazon S3 bucket