Last active
December 2, 2017 19:56
-
-
Save jpfong/bc11159e31edb3380551d4ab778f9a6b to your computer and use it in GitHub Desktop.
Put object in Amazon S3. Note: can only upload one file at a time
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
const aws = require('aws-sdk'); | |
const s3 = new aws.S3(); | |
var params = { | |
Bucket: 'bucket_name', | |
Key: 'file.png', // if you want to put in a directory, the key would be: 'directory_name/file_name.ext' | |
ACL: 'public-read', // to allow to access the file | |
Body: data // the data of the file | |
}; | |
s3.putObject(params, (err, data) => { | |
if (err) { | |
console.error('Error uploading image: ', err); | |
} else { | |
console.log(data); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment