-1

Im new to Firebase storage and i can't for the life of me figure out how to retrieve/list all the folders in my storage.

I have tried reading the docs and i can't find anything on how to solve my specific issue.

Any help here is greatly appreciated. Thank you!

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
Diize
  • 11
  • 1
  • Start with the [documentation](https://firebase.google.com/docs/storage/web/list-files#list_all_files). If you're stuck with what you learned there, post the code that isn't working the way you expect with your debugging details. We can't see where you're stuck now so we can't really help more than what the documentation already provides. – Doug Stevenson Aug 14 '22 at 19:29

1 Answers1

0

You can close this topic as resolved.

Solved by doing this.

const testRef = ref(storage, '/');

  useEffect(() => {
listAll(testRef)
  .then((res) => {
    res.prefixes.forEach((folderRef) => {
      // All the prefixes under listRef.
      // You may call listAll() recursively on them.
      console.log(folderRef.name) //this is where i got the folder names.
    });
    res.items.forEach((itemRef) => {
      // All the items under listRef.
    });
  }).catch((error) => {
    // Uh-oh, an error occurred!
  });
  }, []);
Diize
  • 11
  • 1