I am using aws-sdk using node.js. I want to list images in specified folder e.g.
You can use the Prefix
in s3 API params. I am adding an example that i used in a project:
listBucketContent: ({ Bucket, Folder }) => new Promise((resolve, reject) => {
const params = { Bucket, Prefix: `${Folder}/` };
s3.listObjects(params, (err, objects) => {
if (err) {
reject(ERROR({ message: 'Error finding the bucket content', error: err }));
} else {
resolve(SUCCESS_DATA(objects));
}
});
})
Here Bucket
is the name of the bucket that contains a folder and Folder
is the name of the folder that you want to list files in.