Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

271
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda