I'm looking to list all the objects stored in S3 bucket between two dates using aws s3 javascript sdk.According to ListObjects function there is no parameter allowing to do that except a prefix
or delimiter
but in my case they are useless.
Is there any solution to do that or I have to get the returned data then filter them according to LastModified
?
According to the documentation and the answer I got according to the issue 3102, there is no existing api at the moment of writing this answer, so I do it manually:
async function filteredKeysByDate(startDate, endDate) {
const listedObjects = await s3.listObjects({
Bucket: 'myBucket'
Prefix: 'prefix'})
return listedObjects.reduce((acc, file) => {
if (file.LastModified >= startDate && file.LastModified <= endDate) {
acc= acc.concat(file)
}
return acc;
}, [])
}