6

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?

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
Julien
  • 3,743
  • 9
  • 38
  • 67
  • Check think link: 'https://github.com/googleapis/nodejs-storage/blob/master/samples/files.js'. some useful examples there. first, bucket is storage bucket and files inside that bucket so getFiles() there put all the nested folder path and you got list of resources inside that folder. – phonemyatt Dec 13 '18 at 16:48
  • @phonemyatt any idea about https://stackoverflow.com/questions/53797054/firebase-cloud-function-problem-with-promise-allpromise ? – Julien Dec 15 '18 at 20:40
  • Is there a way to get a specific file in Storage? – Learn2Code Jul 02 '19 at 02:45

1 Answers1

5

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' }

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441