我正在使用 v2 AWS iOS 开发工具包将我的图像上传到服务器我的代码我海峡向前
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 将图像放入对象中。
谢谢