I am creating a simple e-commerce android application. Basically, My business requirement is to show a list of items. Where each item will have a thumbnail image, name, description and few more details like price etc.
I know the basic server client interaction and how json can be fetched from server. My question is what is the best approach for fetching the images?
Few of approaches that comes to my mind are :
- Have a field in json with BASE64 encoded image with in each item and save images as BASE64 text in DB.
- Upload images(in S3 or likewise) and refer them by a URL. Whenever an item is fetched from client(Android app), return URL in item. And once app receives item, it will again send a request to fetch the image.
Pros and Cons
- Latency: Basically, first approach, I am not sure about if how will it perform but certainly encoding and decoding is going to degrade the performance. With the second approach, the major issue is that to fetch the images for items, more network requests are to be made. Like if 10 items arrives for page 1, then 10 more requests to fetch images. And because images will arrive later, there will be empty thumbnails in the list of items.
What should be the best approach to design the system? You are welcome to suggest an alternate beside the above two.
Aucun commentaire:
Enregistrer un commentaire