I am using Firebase Storage in a project but facing one issue that is I want to fetch only the last N number of items (that are recently added ones) from firebase storage is there any way to do so?
one way I saw over the internet is using the list function which returns results using offset and limit but again one problem exists with that function that is I have to retrieve all files then I will reach to last n files this sounds ok at first glance but if data is too much it can make the system slow.
The simplest solution that I can see, would be to store the URL of the file along with the timestamp of the upload operation in a database like Firestore. If you for example need to get the recently n
uploaded files then you can simply perform a query in Firestore and order the results descending by timestamp and limit to results to n
. In this way, you'll be able to read only a fixed number of files and not all the files that exist at a particular location in Storage.