s3upload-coffee-javascript icon indicating copy to clipboard operation
s3upload-coffee-javascript copied to clipboard

The + sign is also used to encode spaces, so it needs to be url encoded....

Open rufman opened this issue 10 years ago • 3 comments

... Amazon does not like other chars such as = to be encoded in the signature, so encoding the whole url doesn't work

rufman avatar Aug 01 '13 02:08 rufman

:+1: yes I had the same problem problem.

"HMAC request signatures must be Base64 encoded. Base64 encoding converts the signature into a simple ASCII string that can be attached to the request. Characters that could appear in the signature string like plus (+), forward slash (/), and equals (=) must be encoded if used in a URI. For example, if the authentication code includes a plus (+) sign, encode it as %2B in the request. Encode a forward slash as %2F and equals as %3D."

You don't need to encode in js, just remove decodeURIComponent and encode whole server side. Code: https://coderwall.com/p/56a9ja

lukasz-madon avatar Mar 29 '14 16:03 lukasz-madon

Use this: signature = signature.replace(/(<([^>]+)>)/ig,""); signature = signature.replace(/+/g, "%2B"); signature = signature.replace(///g, "%2F"); signature = signature.replace(/=/g, "%3D");

rpavez avatar Apr 23 '14 03:04 rpavez

Can you please provide some more info in which case this doesn't work? I'll try to avoid regexp hacks if possible.

tadruj avatar Oct 03 '14 08:10 tadruj