list
Cursor-paginated listing with a prefix filter. Each item is a StoredFile with a lazy body accessor.
files.list(options?)
Cursor-paginated listing with prefix filter. Each item is a StoredFile with a lazy body accessor.
const { items, cursor } = await files.list({
prefix: "avatars/",
limit: 100,
});
if (cursor) {
const next = await files.list({ prefix: "avatars/", cursor });
}Walking every page with listAll
list returns one page plus a cursor; most callers actually want "walk everything under this prefix", which is a manual cursor loop. files.listAll(options?) is that loop as an async iterable:
for await (const file of files.listAll({ prefix: "avatars/" })) {
console.log(file.key, file.size);
}Each item is the same StoredFile list yields. prefix scopes the walk; limit sets the page size each underlying list fetches (not a total cap), and a cursor resumes from a prior position. Every page is a real list call, so it honors the client prefix, retries and timeouts, and fires one onAction list event per page. break out of the loop to stop early — no further pages are fetched.
listAll runs on every adapter, since it's built on list. Two list caveats carry over to the walk:
- Netlify Blobs exposes no pagination cursor. Call
listAll()with nolimitand it returns everything in a single page (correct); pass alimitand there is no next page to follow, so the walk stops at that many. On Netlify, omitlimitwhen you mean "walk everything." - Non-recursive adapters (Box, OneDrive, SharePoint) list only the immediate children of the root folder.
listAllwalks every page, but it can't descend into subfolders the underlyinglistnever returns.
Options
Both list and listAll take the same options:
Prop
Type