Flutter: List of files in a folder in Firebase Clo

2020-02-07 10:00发布

问题:

I need to load some image files from Cloud Storage. For a given folder I need to check what images (if at all) are available in it. It seems like the firebase client library (https://pub.dev/packages/firebase_storage) doesn't have a simple way of doing that. I am sure ios/android clients have ref().list() command. Is there any way to do that easily in Flutter or I have to write a bridge to native methods?

回答1:

The methods to list files in Cloud Storage were only recently added to the Firebase SDKs, so it seems likely that they haven't been ported to the FlutterFire library yet.

You'll indeed either have to implement the interop yourself (in which case a PR back to the repo is highly appreciated), or wait for someone else to implement this feature request (now ported here).

A final alternative is to not depend on this (relatively new) API, and store the list of file paths/download URLs in another data store, such as the Firebase Realtime Database, or Cloud Firestore.