0

我是 Amazon sdk 的新手,我想上传图片,我使用的代码是 Amazon 中的代码,我需要在 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;
                                                   }];
4

1 回答 1

0

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

于 2014-12-22T22:17:28.120 回答