土耳其语上的 AWS S3 SDKv2 和图像上传 ios
AWS S3 SDKv2 and image upload ios on turk
我使用代码将图像上传到 AWS S3:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:pathComp];
[UIImageJPEGRepresentation(myImage,0.9) writeToFile:filePath atomically:NO];
filePath = [NSString stringWithFormat:@"file:///private%@", filePath];
NSURL* fileUrl = [NSURL URLWithString:filePath];
AWSS3TransferManagerUploadRequest *uploadRequest = [AWSS3TransferManagerUploadRequest new];
uploadRequest.key = key;
uploadRequest.body = fileUrl;
uploadRequest.contentType = @"image/jpeg";
上传正常,但在mechanical turk中无法打开预览
This page contains the following errors:
error on line 1 at column 1: Document is empty
error on line 1 at column 1: Encoding error
Below is a rendering of the page up to the first error.
使用 NSURL
创建文件 URL 时,您应该使用 + fileURLWithPath:
。你应该改变这一行
NSURL* fileUrl = [NSURL URLWithString:filePath];
到
NSURL* fileUrl = [NSURL fileURLWithPath:filePath];
您应该仔细检查文件是否已使用 AWS Management Console 成功上传。
此外,默认情况下,所有 Amazon S3 资源(存储桶、对象和相关子资源)都是私有的:只有资源所有者(创建它的 AWS 账户)才能访问该资源。可以修改ACL
来改变权限。
已找到 PaulTaykalo 针对 AWS SDK v2 的解决方案
https://github.com/aws/aws-sdk-ios/issues/10
Link 固定方法
http://pastie.org/9340740
Also added this code to swizzled method
[headers setValue:contentType forKey:@"Content-Type"];
我使用代码将图像上传到 AWS S3:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:pathComp];
[UIImageJPEGRepresentation(myImage,0.9) writeToFile:filePath atomically:NO];
filePath = [NSString stringWithFormat:@"file:///private%@", filePath];
NSURL* fileUrl = [NSURL URLWithString:filePath];
AWSS3TransferManagerUploadRequest *uploadRequest = [AWSS3TransferManagerUploadRequest new];
uploadRequest.key = key;
uploadRequest.body = fileUrl;
uploadRequest.contentType = @"image/jpeg";
上传正常,但在mechanical turk中无法打开预览
This page contains the following errors:
error on line 1 at column 1: Document is empty
error on line 1 at column 1: Encoding error
Below is a rendering of the page up to the first error.
使用 NSURL
创建文件 URL 时,您应该使用 + fileURLWithPath:
。你应该改变这一行
NSURL* fileUrl = [NSURL URLWithString:filePath];
到
NSURL* fileUrl = [NSURL fileURLWithPath:filePath];
您应该仔细检查文件是否已使用 AWS Management Console 成功上传。
此外,默认情况下,所有 Amazon S3 资源(存储桶、对象和相关子资源)都是私有的:只有资源所有者(创建它的 AWS 账户)才能访问该资源。可以修改ACL
来改变权限。
已找到 PaulTaykalo 针对 AWS SDK v2 的解决方案
https://github.com/aws/aws-sdk-ios/issues/10
Link 固定方法 http://pastie.org/9340740
Also added this code to swizzled method
[headers setValue:contentType forKey:@"Content-Type"];