简体   繁体   English

IOS从AWS S3下载图像

[英]IOS Download Images From AWS S3

I am currently uploading images from an IOS app to AWS S3. 我目前正在将图像从IOS应用程序上传到AWS S3。

In order to display images uploaded to S3 i use the methods of the docs 为了显示上传到S3的图像,我使用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? 使用像SDWebImage这样的框架来显示图像有什么好处吗?

The AWS Mobile SDK for iOS does not provide caching. 适用于iOS的AWS Mobile SDK不提供缓存。 You need to manage the files you downloaded from the Amazon S3 buckets for yourself. 您需要自己管理从Amazon S3存储桶下载的文件。 When they suit your use case, cashing frameworks can help you manage the downloaded files. 当它们适合您的用例时,兑现框架可以帮助您管理下载的文件。

You can use SDWebImage from end to end. 您可以SDWebImage使用SDWebImage For that you will have to subclass NSURLProtocol . 为此,您必须子类化NSURLProtocol You can read more about it Here 您可以在此处了解更多信息

Yes, SDWebImage framework manages the image cache very well. 是的,SDWebImage框架可以很好地管理图像缓存。 I will suggest you to try it out. 我建议您尝试一下。 Its easy to use. 它易于使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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