Skip to content

S3RequestPresigner#presign causes SignatureDoesNotMatch error when S3 object key contains = #4862

Answered by yenfryherrerafeliz
sayyajp asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @sayyajp, sorry to hear about your issues. By reading the documentation about key naming guidelines, which can be found here, we can see that the symbol "=" is an special character and need special handling. Basically, in this case what you need to do is to URI-encode the key parameter. This is already handle by the getSignedUrl method, but since you are customizing your request then you need to do it yourself. Here is an example for how you can do it:
Instead of:

const apiUrl = new URL(
    `https://${params.bucket}.s3.amazonaws.com/${params.key}`
)

You need to do:

const apiUrl = new URL(
    `https://${params.bucket}.s3.amazonaws.com/${encodeURIComponent(params.key)}`
);

And that sho…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@nam178
Comment options

Answer selected by yenfryherrerafeliz
Comment options

You must be logged in to vote
1 reply
@sayyajp
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.
3 participants
Converted from issue

This discussion was converted from issue #4859 on June 20, 2023 19:25.