Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase storage : list files in a specific directory

How to list files in Firebase storage in a specific directory (eg: /test),

Here is what I tried :

 var query = {
    delimiter: 'test/'
};

const storageRef = admin.storage().bucket().getFiles(query, function(err, files, nextQuery, apiResponse) {

  console.log(files);
}

but it returns files at the root of the bucket..

Any idea?

like image 740
Julien Avatar asked Dec 13 '18 08:12

Julien


People also ask

How do I find the path of a file in Firebase Storage?

If you want the file path on firebase storage to access it via storage reference and not URL, you can use taskSnapshot. getStorage().

Can Firebase store lists?

Save and categorize content based on your preferences. Cloud Storage for Firebase allows you to list the contents of your Cloud Storage bucket.

How do I search in Firebase Storage?

There is no way to list files, search for files or filter files within the Firebase Storage API. There are some such features in the gcloud API, which can also be used on Firebase Storage. This user is first on the weekly Google Cloud leaderboard.

Is Firebase Storage same as Google Cloud Storage?

The new Firebase Storage is powered by Google Cloud Storage, giving it massive scalability and allowing stored files to be easily accessed by other projects running on Google Cloud Platform. Firebase now uses the same underlying account system as GCP, which means you can use any GCP product with your Firebase app.


1 Answers

It looks like you're not passing the correct object to getFiles(). The documentation for the GetFilesRequest object suggests that you should be passing a property called directory, not delimiter. If you want all the files under /test, then pass { directory: '/test' }

like image 166
Doug Stevenson Avatar answered Sep 22 '22 09:09

Doug Stevenson