I'm trying to delete an object from S3 and I can't make it work.
This is what I'm doing:
const AWS = require('aws-sdk');
const s3 = new AWS.S3({
accessKeyId: ID, //My accessKeyId
secretAccessKey: SECRET //My secretAccessKey
});
var params = {
Bucket: process.env.S3_BUCKET_NAME, //'myBucket'
Key: file //'places-images/06850015-3d55-427b-a2f3-b8c2a56a42d8madametussauds.jpg'
}
s3.deleteObject(params, (err, data) => {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
})
The data object returned is always empty and the file does not go away from S3. This bucket is not versioned btw.
I tried the examples from here and AWS docs but don't seem to work. It's driving me crazy because it seems pretty straighforward! Any help will be greatly appretiated!