我正在使用v2 AWS iOS SDK将我的图像上传到服务器 我的代码我是前进的
NSString * uniqueIdentifier = [[NSUUID UUID]UUIDString];
AWSS3TransferManagerUploadRequest *uploadRequest = [AWSS3TransferManagerUploadRequest new];
uploadRequest.bucket = @"my bucket";
uploadRequest.key = [NSString stringWithFormat:@"%@/images/%@.jpeg",objectId,uniqueIdentifier];
uploadRequest.ACL = AWSS3ObjectCannedACLPublicRead;
NSData * data = UIImageJPEGRepresentation(newImage, 0.8);
NSString *tmpDirectory = NSTemporaryDirectory();
NSString *tmpFile = [tmpDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.jpeg",uniqueIdentifier]];
NSLog(@"Temp File:%@", tmpFile);
[data writeToFile:tmpFile atomically:YES];
uploadRequest.body = [NSURL fileURLWithPath:tmpFile];
AWSS3TransferManager *transferManager = [AWSS3TransferManager defaultS3TransferManager];
[[transferManager upload:uploadRequest] continueWithExecutor:[BFExecutor defaultExecutor]
withBlock:^id(BFTask *task) {
if (task.error != nil) {
NSLog(@"%s %@","Error uploading :", uploadRequest.key);
}else {
AWSS3TransferManagerUploadOutput * output = task.result;
NSLog(@"Upload completed %@",[output description]);
}
return nil;
}];
将文件上传到S3服务后,响应URL在哪里? 我怎么知道那张图片的网址? 我想通过DB将图像放在一个对象中。
感谢
答案 0 :(得分:1)
可公开阅读的Amazon S3对象遵循以下URL模式:
https://S3Endpoint/BucketName/ObjectName
查找对象网址的最简单方法是转到对象“链接:”的AWS Management Console和look。