Skip to content

Instantly share code, notes, and snippets.

@jpfong
Last active December 2, 2017 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpfong/18cfb74b72a686fbe0c43e9bd04af95f to your computer and use it in GitHub Desktop.
Save jpfong/18cfb74b72a686fbe0c43e9bd04af95f to your computer and use it in GitHub Desktop.
Delete a single object in AWS S3.
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