List files and folders
folder and prefix terminology
The API describes folders as prefixes, but the docs also mention folders.
folder existence
A file, by its name alone, may create several nested folders because we read it as a path. For example, abc/def/hello.pdf creates two folders: abc and def. Those folders do not exist per se, but only because we follow this arbitrary convention.
In this convention, folders can't be empty: if there is a folder, there is a nested file.
get references at folder level
We build a reference to a folder and list its content. The list API trims the nested items (shallow list).
The list discriminates files (items) from folders (prefixes), but both are exposed as references (StorageReference_). The list exposes them as two arrays.
folderRef = ref(storage, "uploads")
const result = await list(directoryRef, { maxResults: 100 })
// const result = await listAll(directoryRef)
result.items // StorageReference[]
result.prefixes // StorageReference[]