I couldn't find resources discussing the difference between the three download methods in the firebase storage documentation and pros/cons of each. I would like some clarification about the firebase storage documentation.
My App
- Displays 100 images ranging from 10 KB-500 KB in size on a table view
- Will be used in a location where internet connection and/or phone service could be very weak
- Could be used by many users
3 methods for downloading from Firebase storage
- Download to
NSDatain memoryThis is the easiest way to quickly download a file, but it must load entire contents of your file into memory. If you request a file larger than your app's available memory, your app will crash. To protect against memory issues, make sure to set the max size to something you know your app can handle, or use another download method.
Question: I tried this method to display 100 images that were 10KB-500KB in size on my table view cells. Although my app didn't crash, as I scrolled through my table, my memory usage increased to 268 mb. Would this method not be recommended for displaying a lot of images?
- Download to an
NSURLrepresenting a file on deviceThe
writeToFile:completion:method downloads a file directly to a local device. Use this if your users want to have access to the file while offline or to share in a different app.
Question: Does that mean all images from firebase storage will be downloaded on user's phone? Does that mean that the app will be taking up a large percentage of the available storage on the phone?
- Generate an
NSURLrepresenting the file online
If you already have download infrastructure based around URLs, or just want a URL to share, you can get the download URL for a file by calling the
downloadURLWithCompletion:method on a storage reference.
Question: Does this method require a strong internet connection and/or phone service connection to work?