Skip to content

Instantly share code, notes, and snippets.

@nickwild-999
Forked from cassiozen/slsFileUploadHandler.js
Created January 26, 2021 23:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickwild-999/f06b674e1497c2b1404f12df9413f104 to your computer and use it in GitHub Desktop.
Save nickwild-999/f06b674e1497c2b1404f12df9413f104 to your computer and use it in GitHub Desktop.
module.exports.requestUploadURL = (event, context, callback) => {
var s3 = new AWS.S3();
var params = JSON.parse(event.body);
var s3Params = {
Bucket: 'slsupload',
Key: params.name,
ContentType: params.type,
ACL: 'public-read',
};
var uploadURL = s3.getSignedUrl('putObject', s3Params);
callback(null, {
statusCode: 200,
headers: {
'Access-Control-Allow-Origin': 'https://www.my-site.com'
},
body: JSON.stringify({ uploadURL: uploadURL }),
})
}
@nickwild-999
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment