Reputation: 6674
I am trying to allow access to assets from a presigned URL but I am unsure of how to do this. From this page I can see I need the following:
Authorization = "AWS" + " " + AWSAccessKeyId + ":" + Signature; Signature = Base64( HMAC-SHA1( YourSecretAccessKeyID, UTF-8-Encoding-Of( StringToSign ) ) ); StringToSign = HTTP-Verb + "\n" + Content-MD5 + "\n" + Content-Type + "\n" + Date + "\n" + CanonicalizedAmzHeaders + CanonicalizedResource; CanonicalizedResource = [ "/" + Bucket ] + <HTTP-Request-URI, from the protocol name up to the query string> + [ subresource, if present. For example "?acl", "?location", "?logging", or "?torrent"]; CanonicalizedAmzHeaders = <described below>
I know how to find the AWSAccessKeyId
and the YourSecretAccessKeyID
but how do I encode it using HMAC-SHA1
to form the final signature?
Upvotes: 2
Views: 2420
Reputation: 6674
I was able to generate a presigned URL for fetching files like according to this Amazon S3 node example page:
declare var AWS:any;
AWS.config.accessKeyId = "key_goes_here";
AWS.config.secretAccessKey = "secret_key_goes_here";
AWS.config.region = "region_goes_here";
params = {
Bucket: 'bucket_name_goes_here',
Key: 'path_to_file_goes_here'
}
s3.getSignedUrl('getObject', params, function (err, url) {
// Do some sort of processing with url
});
Upvotes: 5