how to use AWSS3 TransferManager upload Request to upload image objective c?

482 views Asked by At

i new with the Amazon sdk, and i want to upload image , the code i use is the code in Amazon, What i need to enter in body for upload image?:

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;
                                                   }];
1

There are 1 answers

0
Eneko Alonso On

request.body should be set to an NSURL from a file stored on your device. You can save your UIImage to disk (document or cache) using NSFileManager.