objective-ccore-dataamazon-web-servicesamazon-s3awss3transfermanager

Which is a better way: retrieve images from AWS S3 or download it and store locally in a temp folder to be displayed?


Problem: Retrieve image from S3 and load into UIButton.

I'm currently doing my research on this issue and can't seem to make up my mind. Which is a better way to do it in terms of performance and security issue?

Also, do I need to do caching or store these images in Core Data?

Thanks!


Solution

  • It depends on how you use them. If your app is going to retrieve the images similiar to instagram, or twitter, it's good to download them as the user requested the images via the app.

    If once the images are retrieved, the application going to use the images again and again multiple times, it's a good idea to store the images after they are downloaded.

    For example, let's think about an application about "social networking" concept, and this app, let's say, has a chat interface which is functional after users add each other. As the users add each other, you download the images of the users and store them on the device, then you can use the profile images of the users by retrieving the locally stored images rather than retrieving them from the server, thus, each time they chat each other, you dont use the bandwidth for nothing. And you should also use a push notification or something that has a similiar functionality for the scenario, when a user changes his profile pictures, all of his/her friends should also be notified (I mean the app is going to be notified by the server) to retrieve and update their local profile image with the newly added ones.

    As I said, it depenends on the scenarios of your application/server relationship. If the images you are storing on the AWS S3 are only going to be used only once, then storing them is useless. And If the user is going to use some of the images frequently (like app is a social networking app, friendship app and the friends are going to see each other's photo or uploaded images frequently), then storing them is a good idea, only for some of the users that who has subscribed to each other.