1import { ListObjectsV2Command } from '@aws-sdk/client-s3' 4export const listObjectsByPrefix = async ({bucket_name, prefix, maxKeys = 1000}: { 5 bucket_name: string, prefix: string, maxKeys?: number 8 const contentsA: {Key?: string, LastModified?: Date, Size?: number}[] = [] 9 let continuationToken: string | undefined 11 const resp = await s3.send(new ListObjectsV2Command({ 12 Bucket: bucket_name, Prefix: prefix, MaxKeys: maxKeys, ContinuationToken: continuationToken, 14 for (const obj of resp.Contents ?? []) contentsA.push(obj as any) 15 continuationToken = resp.IsTruncated ? resp.NextContinuationToken : undefined 16 } while (continuationToken)