Skip to main content

Listing Files

List files in a storage bucket with pagination using ductape.storage.listFiles().

Parameters​

FieldTypeRequiredDefaultDescription
productstringYes—Product tag.
envstringYes—Environment slug (e.g. prd, dev).
storagestringYes—Storage configuration tag.
prefixstringNo—Prefix to filter keys (e.g. documents/).
limitnumberNo100Max results per page (max: 1000).
continuationTokenstringNo—Token for the next page (from previous result).
cachestringNo—Optional cache tag for caching the result.

Example​

const result = await ductape.storage.listFiles({
storage: 'primary-storage',
prefix: 'uploads/',
limit: 20,
});

console.log('Files:', result.files);
console.log('Has more:', result.hasMore);
console.log('Next token:', result.nextToken);

Response​

FieldTypeDescription
successbooleanWhether the request succeeded.
filesarrayList of file metadata objects.
limitnumberPage size.
nextTokenstring?Token to pass as continuationToken for the next page.
hasMorebooleanWhether more results are available.

Each file in files has: name, size, lastModified, and optionally url, mimeType, metadata.

Pagination​

Use continuationToken and nextToken to fetch the next page:

let token: string | undefined;
do {
const result = await ductape.storage.listFiles({
storage: 'primary-storage',
limit: 100,
continuationToken: token,
});
// process result.files
token = result.nextToken;
} while (token);

See Also​