Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ var policy = myS3Account.writePolicy('myfile', 'mybucket', 60, 10);
````

* Website: http://www.arbitrarytech.com

Please note that the key is optional on the readPolicy method. A key for the bucket only may be generated.
12 changes: 10 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ function s3instance(accessKey, secretKey) {
expiration = Math.round(expiration.getTime() / 1000);

var policy = 'GET\n\n\n' + expiration + '\n';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this line removed?

policy += '/' + bucket;
if (key){
policy += '/';
policy += key;
}
policy += '/' + bucket + '/' + key;
if (download) {
policy += '?response-content-disposition=attachment;filename=' + encodeURIComponent(download);
Expand All @@ -23,8 +28,11 @@ function s3instance(accessKey, secretKey) {
var signature = crypto.createHmac("sha1", this.secretKey).update(policy);

var url = 'https://s3.amazonaws.com/';
url += bucket + '/';
url += key;
url += bucket;
if (key) {
url += '/';
url += key;
}
url += '?AWSAccessKeyId=' + this.accessKey;
url += '&Expires=' + expiration;
url += '&Signature=' + encodeURIComponent(signature.digest("base64"));
Expand Down