Created
January 18, 2019 11:47
-
-
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.
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'); | |
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