I am new to AWS. I am creating a Scheduled lambda function using NodeJS. There I need to get all the objects in a folder and iterate through each, to check the last modified date and I want to delete old objects. But I am getting empty array in ListObject's Response Contents.
var s3 = new aws.S3();
exports.handler = (event, context, callback) => {
var params = {
Bucket: 'bucket_name',
Delimiter: '/',
Prefix: 'folder_name',
MaxKeys:100000
};
s3.listObjects(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else
{
var folderLength = data.Contents.length;
data.Contents.forEach(function(metadata) {
console.log('Key: ' + metadata.Key);
});
}
});
callback(null, 'Finished');
};
But in the response i am getting Contents: []
. Can anyone tell me whats wrong?
via Salini
No comments:
Post a Comment