简体   繁体   中英

IOS Download Images From AWS S3

I am currently uploading images from an IOS app to AWS S3.

In order to display images uploaded to S3 i use the methods of the docs

// Construct the NSURL for the download location.
NSString *downloadingFilePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"downloaded-myImage.jpg"];
NSURL *downloadingFileURL = [NSURL fileURLWithPath:downloadingFilePath];

// Construct the download request.
AWSS3TransferManagerDownloadRequest *downloadRequest = [AWSS3TransferManagerDownloadRequest new];

downloadRequest.bucket = @"myBucket";
downloadRequest.key = @"myImage.jpg";
downloadRequest.downloadingFileURL = downloadingFileURL;

And then to download the image with the method

[[transferManager download:downloadRequest] continueWithExecutor:[BFExecutor mainThreadExecutor]
                                                   withBlock:^id(BFTask *task)

I am concerned about the download location : could there be memory issues if too many images are downloaded?

If someone has already been using this framework, are there any caching capabilities to set manually? Is there any advantage of using a framework like SDWebImage to display images?

The AWS Mobile SDK for iOS does not provide caching. You need to manage the files you downloaded from the Amazon S3 buckets for yourself. When they suit your use case, cashing frameworks can help you manage the downloaded files.

You can use SDWebImage from end to end. For that you will have to subclass NSURLProtocol . You can read more about it Here

Yes, SDWebImage framework manages the image cache very well. I will suggest you to try it out. Its easy to use.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM