How to get a list of all files in Cloud Storage in a Firebase app?

Luis Ruiz Figueroa picture Luis Ruiz Figueroa · May 20, 2016 · Viewed 104.6k times · Source

I'm working on uploading images, everything works great, but I have 100 pictures and I would like to show all of them in my View, as I get the complete list of the images in a folder, I can not find any API for this work.

Answer

Frank van Puffelen picture Frank van Puffelen · May 20, 2016

Since Firebase SDKs for JavaScript release 6.1, iOS release 6.4, and Android release version 18.1 all have a method to list files.

The documentation is a bit sparse so far, so I recommend checking out Rosário's answer for details.


Previous answer, since this approach can still be useful at times:

There currently is no API call in the Firebase SDK to list all files in a Cloud Storage folder from within an app. If you need such functionality, you should store the metadata of the files (such as the download URLs) in a place where you can list them. The Firebase Realtime Database and Cloud Firestore are perfect for this and allows you to also easily share the URLs with others.

You can find a good (but somewhat involved) sample of this in our FriendlyPix sample app. The relevant code for the web version is here, but there are also versions for iOS and Android.