Skip to content

Instantly share code, notes, and snippets.

@fulopdaniel
Created September 6, 2018 13:21
Show Gist options
  • Save fulopdaniel/291b60ac09d5617368d47ae9259b1655 to your computer and use it in GitHub Desktop.
Save fulopdaniel/291b60ac09d5617368d47ae9259b1655 to your computer and use it in GitHub Desktop.
const uploadFile = (buffer) => new Promise((resolve, reject) => {
const bucketName = "YOUR-BUCKET-NAME";
const fileName = "YOUR-FILE-NAME.EXTENSION";
const data = {
Bucket: bucketName,
Key: fileName,
Body: buffer,
};
s3.putObject(data, (error) => {
if (!error) {
resolve('success');
} else {
reject(new Error('error during put'));
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment