3

我正在使用 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 将图像放入对象中。

谢谢

4

1 回答 1

1

公开可读的 Amazon S3 对象遵循以下 URL 模式:

https://S3Endpoint/BucketName/ObjectName

找出对象 URL 的最简单方法是转到AWS 管理控制台查看对象的“链接:”。

于 2015-02-24T20:06:33.060 回答