Skip to content

Instantly share code, notes, and snippets.

@bmorrisondev
Created January 18, 2019 11:47
Show Gist options
  • Save bmorrisondev/1c2c9852d0160bd1a01f8593b92337a6 to your computer and use it in GitHub Desktop.
Save bmorrisondev/1c2c9852d0160bd1a01f8593b92337a6 to your computer and use it in GitHub Desktop.
A quick snippet that can be used to upload a file to an S3 bucket.
const AWS = require('aws-sdk');
function putObjectToS3(bucket, key, data){
return new Promise((resolve, reject) => {
let s3 = new AWS.S3();
var params = {
Bucket : bucket,
Key : key,
Body : data
}
s3.putObject(params, function(err, data) {
if (err) {
reject(err);
} else {
resolve(data);
}
});
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment