Skip to content

Instantly share code, notes, and snippets.

@eventhough
Last active August 29, 2015 14:24
Show Gist options
  • Save eventhough/ffdd74568fd0e1e7a4e5 to your computer and use it in GitHub Desktop.
Save eventhough/ffdd74568fd0e1e7a4e5 to your computer and use it in GitHub Desktop.
Method to generate signed URL for AWS S3
var aws = require('aws-sdk');
aws.config.update({
accessKeyId: AWS_ACCESS_KEY
secretAccessKey: AWS_SECRET_KEY
});
exports = module.exports = {
sign: function(filename, filetype) {
var s3 = new aws.S3();
var params = {
Bucket: SOME_BUCKET,
Key: filename,
Expires: 60,
ContentType: filetype
};
s3.getSignedUrl(‘putObject’, params, function(err, data) {
if (err) {
console.log(err);
return err;
} else {
return data;
}
});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment