I want to delete all the objects from an s3 bucket that has the key with the certain pattern. My questions??
Can I simply pass regular expression on the key value as illustrated in the code below?
One option would be to list all the objects and filter the keys that matches the regular expression and add them all to the deleteObjects method. I find this inefficient. So, any other way around? Would be a great help? Thanks in advance...
var params = {
Bucket: 'sample_bucket',
Delete: {
Objects: [
{
Key: '/video-044567/g' // here i want something like that
},
],
},
};
s3.deleteObjects(params, function(err, data) {
if (err) console.log(err, err.stack);
else console.log(data);
});