【问题标题】:how to use AWSS3 TransferManager upload Request to upload image objective c?如何使用 AWSS3 TransferManager 上传请求上传图像目标 c?
【发布时间】:2015-02-07 07:11:20
【问题描述】:

我是亚马逊sdk的新手,我想上传图片,我使用的代码是亚马逊的代码,我需要在body中输入什么来上传图片?:

AWSS3TransferManager *transferManager = [AWSS3TransferManager defaultS3TransferManager];

AWSS3TransferManagerUploadRequest *request = [[AWSS3TransferManagerUploadRequest alloc] init];
request.bucket = kBucket;
request.key = fileName;
request.body =url;
request.contentType = @"image/jpeg";


[[transferManager upload:request] continueWithExecutor:[BFExecutor mainThreadExecutor]
                                                   withBlock:^id(BFTask *task) {
                                                       NSLog(@"ckmdkcd dvdsv");
                                                       if (task.error) {
                                                           if ([task.error.domain isEqualToString:AWSS3TransferManagerErrorDomain]) {
                                                               switch (task.error.code) {
                                                                   case AWSS3TransferManagerErrorCancelled:
                                                                   case AWSS3TransferManagerErrorPaused:
                                                                       break;

                                                                   default:
                                                                       NSLog(@"Error: %@", task.error);
                                                                       break;
                                                               }
                                                           } else {
                                                               // Unknown error.
                                                               NSLog(@"Error: %@", task.error);
                                                           }
                                                       }

                                                       if (task.result) {
                                                           AWSS3TransferManagerUploadOutput *uploadOutput = task.result;
                                                           // The file uploaded successfully.
                                                       }
                                                       return nil;
                                                   }];

【问题讨论】:

    标签: image amazon-s3 upload image-uploading awss3transfermanager


    【解决方案1】:

    request.body 应设置为存储在设备上的文件中的 NSURL。您可以使用 NSFileManager 将 UIImage 保存到磁盘(文档或缓存)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-08-25
      • 2011-07-22
      • 2019-07-31
      • 2015-12-04
      • 2015-11-20
      • 1970-01-01
      相关资源
      最近更新 更多