Encoding spaces in s3.getSignedUrl() parameter

Viewed 1002

I am getting a "SignatureDoesNotMatch" 403 error from AWS from pre-signed urls for items in S3 when there is a space in the key name. Of course spaces in key names are a bad idea.

When requesting the getSignedUrl, I've tried replacing the space with a plus sign, I've tried replacing spaces with %20, I tried various encoding schemes all to no avail.

key = "SOMEBUCKET/my file with a space.jpg";
key = key.replace(/ /g,"%20");
params.Key = key
s3Client.getSignedUrl('getObject', params, function(err, url) { }

What i get back is an error doc:

<Code>SignatureDoesNotMatch</Code>
<Message>
The request signature we calculated does not match the signature you 
provided. Check your key and signing method.
</Message>...

How to encode this so i can use S3.getSignedUrl() with spaces in key? Thanks StackOverflow world for your help.

0 Answers
Related