Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

270
Views
list all files in firebase storage v9

I am developing a page and am using firebase storage as the file storage. I tried using the given codes in the firebase developer docs but I can't seem to make it work. What could be the problem?

document.getElementById("but").addEventListener('click', e => {

    // Create a reference under which you want to list
    const listRef = ref(storage, 'folder/');
    // Find all the prefixes and items.
    listAll(listRef)
        .then((res) => {
            res.prefixes.forEach((folderRef) => {
                // All the prefixes under listRef.
                // You may call listAll() recursively on them.
            });
            res.items.forEach((itemRef) => {
                // All the items under listRef.
                console.log( getDownloadURL(ref(storage, `folder/${itemRef}`)))
            })
        })
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I'm not sure what problem you have with the code, but one mistake is in :

res.items.forEach((itemRef) => {
    // All the items under listRef.
    console.log( getDownloadURL(ref(storage, `folder/${itemRef}`)))
})

The getDownloadURL function performs an asynchronous call to the server, so you'll need to either use await or then to capture that result:

res.items.forEach((itemRef) => {
    getDownloadURL(ref(storage, `folder/${itemRef}`))
        .then((downloadURL) => {
            console.log(downloadURL);
        });
})
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!