Reputation: 25
I am uploading audio files (as blobs) to firebase and each file has an attached metadata. The metadata contains a custom value reviewed that's either true or false. I want to use the list() firebase function to display said files, but I only want the files that have reviewed : false to be displayed. How can I go about this?
From what I have read you can sort/manipulate values in a child(), but I don't completely understand how to do that; instead of using metadata, is it possible to add the reviewed : false section to the child? As far as I know that can't be done since it is an audio file. I don't have any code yet to show since I don't know where to start, any help would be appreciated!
Upvotes: 0
Views: 1296
Reputation: 598807
The Firebase SDK for Cloud Storage can only filter based on path-prefix, so in which "directory" the files are. There is no option to filter on metadata.
That means you currently have a few options:
Store the unreviewed files in a different path, so that you can list them filtering on path prefix. For example, if you store the unreviewed files in a directory/folder/location unreviewed
, you can then get only the unreviewed files with firebase.storage().ref().child('unreviewed').list()...
This means you'll have to move the file to a different location after you've reviewed it though. Since moving files isn't an operation in the Firebase API, you'll either have to re-upload the file (which also allows you to update the metadata), or use the Cloud/server-side APIs to move the file.
Store the metadata about the file's review status in another location, such as the Firebase Realtime Database, or Cloud Firestore. This is the most common approach by far, as you can typically more easily store, update, and query the metadata about the file in this database, using Cloud Storage purely for the reads and writes of the binary data.
See also the "previous answer" paragraph in this previous answer I gave.
Upvotes: 3