AFAmazonS3Manager错误

时间:2015-04-04 20:33:50

标签: objective-c amazon-web-services amazon-s3 xcode6

我试图在我的应用中使用AFAmazonS3Manager。我试图将照片上传到亚马逊,但我一直收到此错误:

Error Domain=NSURLErrorDomain Code=-1100 "The requested URL was not found on this server." UserInfo=0x1740e3f00 {NSUnderlyingError=0x170247dd0 "The requested URL was not found on this server.", NSErrorFailingURLStringKey=file:///var/mobile/Containers/Data/Application/myInfo, NSErrorFailingURLKey=file:///var/mobile/Containers/Data/Application/myInfo, NSLocalizedDescription=The requested URL was not found on this server.

我的代码很简单:

    AFAmazonS3Manager * s3Manager = [[AFAmazonS3Manager alloc]initWithAccessKeyID:amazonAccessKey secret:amazonSecret];
s3Manager.requestSerializer.region = AFAmazonS3USStandardRegion;
s3Manager.requestSerializer.bucket = amazonBucket;

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:photoName];
[UIImagePNGRepresentation(photo) writeToFile:filePath atomically:YES];

[s3Manager postObjectWithFile:filePath destinationPath:@"" parameters:nil progress:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {

    int percent = roundf((float)totalBytesWritten / (float)totalBytesExpectedToWrite * 100);
    NSLog(@"Percent Complete: %d%%",percent);

我已经解决了这个问题几天了。我是使用AWS的新手,所以我不知道自己做错了什么。

1 个答案:

答案 0 :(得分:0)

您可能会传递无效的请求网址,或者根据错误消息提供的图片并不存在于您提供的路径中。请检查网址路径如果图像确实存在,或者通过复制粘贴浏览器中的网址有效,则可以使用它。这里有一个可能对您有所帮助的链接:http://www.splinter.com.au/2014/10/15/upload-to-s3-from-ios/