method
bun.S3Client.list
list(
options?: Pick<S3Options, 'accessKeyId' | 'secretAccessKey' | 'sessionToken' | 'region' | 'bucket' | 'endpoint'>
Returns some or all (up to 1,000) of the objects in a bucket with each request.
Use the request parameters as selection criteria to return a subset of the objects in a bucket.
@param input
Options for listing objects in the bucket
@param options
Additional S3 options to override defaults
@returns
A promise that resolves to the list response
// List (up to) 1000 objects in the bucket
const allObjects = await bucket.list();
// List (up to) 500 objects under `uploads/` prefix, with owner field for each object
const uploads = await bucket.list({
prefix: 'uploads/',
maxKeys: 500,
fetchOwner: true,
});
// Check if more results are available
if (uploads.isTruncated) {
// List next batch of objects under `uploads/` prefix
const moreUploads = await bucket.list({
prefix: 'uploads/',
maxKeys: 500,
startAfter: uploads.contents!.at(-1).key,
fetchOwner: true,
});
}