Explore Courses Blog Tutorials Interview Questions
0 votes
in AWS by (5.6k points)

I only have UIImages in memory and want to upload them, So is it possible to upload a UIImagw to S3 using SDK?

1 Answer

0 votes
by (12.4k points)

AWS iOS SDK v2 will not support the uploading of images from memory. Here, what you can do is to save them as s file, and then you will be able to upload them.

Refer to the below code:

//image you want to upload

UIImage* imageToUpload = [UIImage imageNamed:@"imagetoupload"]; 

//convert uiimage to 

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png", dateKey]];

[UIImagePNGRepresentation(imageToUpload) writeToFile:filePath atomically:YES];

NSURL* fileUrl = [NSURL fileURLWithPath:filePath];

//upload the image

AWSS3TransferManagerUploadRequest *uploadRequest = [AWSS3TransferManagerUploadRequest new];

uploadRequest.body = fileUrl;

uploadRequest.bucket = AWS_BUCKET_NAME;

uploadRequest.key = @"yourkey";

uploadRequest.contentType = @"image/png";

[[transferManager upload:thumbNailUploadRequest] continueWithExecutor:[BFExecutor mainThreadExecutor] withBlock:^id(BFTask *task) {

    if(task.error == nil) {



    return nil;


Do you want to learn more about AWS? Checkout aws certification training by Intellipaat!

Related questions

0 votes
1 answer

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer

Browse Categories