List files and folders
folders and prefix terminology
The API describes folders as prefixes, but the docs also mention folders.
folder existence
A file, by its name alone, can create one or more nested folders. It occurs when its name contains subpaths. For example, abc/def/hello.pdf creates two folders: abc and def. Those folders are an artificial byproduct.
By design, those folders can't be empty, because they derive from a nested file.
use a folder reference to list its content
We build a folder reference to list its content. It outputs a shallow list: we see the top level files and folders.
The list discriminates files (items) from folders (prefixes), putting them into separate arrays, but both arrays are typed with the same StorageReference element type.
Note: list() is a capped version that expects a count limit.
folderRef = ref(storage, "uploads")
const result = await listAll(folderRef)
const result = await list(folderRef, { maxResults: 100 })
result.items // StorageReference[]
result.prefixes // StorageReference[]