Last active
December 2, 2017 19:56
-
-
Save jpfong/18cfb74b72a686fbe0c43e9bd04af95f to your computer and use it in GitHub Desktop.
Delete a single object in AWS S3.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var aws = require('aws-sdk'); | |
var s3 = new aws.S3(); | |
var params = { | |
Bucket: 'bucket', | |
Key: 'file.png' // if the file is a in a directory, the key would be: 'directory_name/file_name.ext' | |
}; | |
s3.deleteObject(params, (err, data) => { | |
if (err) { | |
console.error(err) | |
} else { | |
console.log('File deleted successfully', data); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment