Good catch! Here's the solution in node.js in case it will help anyone:
signs3: function(req, res){
var AWSACCESSKEY = <access key from config>;
var AWSSECRETKEY = <secret key from config>;
var S3BUCKET = <bucket name>;
var object_name = uuid.v4(); //I'm using uuids as my object_names
var mime_type = req.query.s3_object_type;
var now = new Date();
var expires = Math.ceil((now.getTime() + 60000)/1000); // 60 seconds from now
var amz_headers = "x-amz-acl:public-read";
var put_request = "PUT\n\n"+mime_type+"\n"+expires+"\n"+amz_headers+"\n/"+S3_BUCKET+"/"+object_name;
var signature = crypto.createHmac('sha1', AWS_SECRET_KEY).update(put_request).digest('base64');
signature = signature.replace('+','%2B')
.replace('/','%2F')
.replace('=','%3D');
signature = encodeURIComponent(signature.trim());
var url = 'https://'+S3_BUCKET+'.s3.amazonaws.com/'+object_name;
var credentials = {
signed_request: url+"?AWSAccessKeyId="+AWS_ACCESS_KEY+"&Expires="+expires+"&Signature="+signature,
url: url
};
res.write(JSON.stringify(credentials));
res.end();
},
Achievements
19
Karma
0
Total ProTip Views
Charity
Fork and commit to someone's open source project in need
Mongoose
Have at least one original repo where Ruby is the dominant language
Good catch! Here's the solution in node.js in case it will help anyone:
signs3: function(req, res){
var AWSACCESSKEY = <access key from config>;
var AWSSECRETKEY = <secret key from config>;
var S3BUCKET = <bucket name>;
},