Skip to content

Instantly share code, notes, and snippets.

@HyunSeob
Last active May 27, 2017 06:20
Show Gist options
  • Save HyunSeob/3a809febbfc44eba55e4cb7618080261 to your computer and use it in GitHub Desktop.
Save HyunSeob/3a809febbfc44eba55e4cb7618080261 to your computer and use it in GitHub Desktop.
const AWS = require('aws-sdk');
const BUCKET_NAME = 'your-s3-bucket-name';
const s3 = new AWS.S3();
exports.handler = (event, context, callback) => {
const { name, body } = event;
s3.putObject({
Bucket: BUCKET_NAME,
Key: `${name}.txt`,
ContentType: 'text/plain',
Body: body,
}, (err, data) => {
if (err) {
return callback(err);
}
callback(null, data);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment