【问题标题】:AWSS3TransferManagerUploadRequest get response URLAWSS3TransferManagerUploadRequest 获取响应 URL
【发布时间】:2015-04-26 07:22:04
【问题描述】:

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

谢谢

【问题讨论】:

    标签: ios amazon-s3 aws-sdk-ios


    【解决方案1】:

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

    https://S3Endpoint/BucketName/ObjectName
    

    找出对象 URL 的最简单方法是转到对象的“链接:”处的 AWS Management Consolelook

    【讨论】:

      猜你喜欢
      • 2011-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多