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, creates nested folders, when its name contains subpaths. For example, abc/def/hello.pdf creates two folders: abc and def. Those folders do not exist on their own: they 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 reference to a folder to list its content. It is a shallow list: we see the top level files and folders.

The list discriminates files (items) from folders (prefixes), putting them into separate arrays. The item itself is exposed as a reference (StorageReference) regardless if it is a file or a folder.

Note: list() is a capped version that expects a count limit.

folderRef = ref(storage, "uploads")

const result = await list(directoryRef, { maxResults: 100 })
// const result = await listAll(directoryRef)

result.items // StorageReference[]
result.prefixes // StorageReference[]
earlymorning logo

© Antoine Weber 2026 - All rights reserved

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, creates nested folders, when its name contains subpaths. For example, abc/def/hello.pdf creates two folders: abc and def. Those folders do not exist on their own: they 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 reference to a folder to list its content. It is a shallow list: we see the top level files and folders.

The list discriminates files (items) from folders (prefixes), putting them into separate arrays. The item itself is exposed as a reference (StorageReference) regardless if it is a file or a folder.

Note: list() is a capped version that expects a count limit.

folderRef = ref(storage, "uploads")

const result = await list(directoryRef, { maxResults: 100 })
// const result = await listAll(directoryRef)

result.items // StorageReference[]
result.prefixes // StorageReference[]