I have searched on the web for over two days now, and probably have looked through most of the online documented scenarios and workarounds, but nothing worked for me so far.
This error seems to occur mostly if there is a space before or after your secret key
For me I used axios and by deafult it sends header
content-type: application/x-www-form-urlencoded
so i change to send:
content-type: application/octet-stream
and also had to add this Content-Type to AWS signature
const params = {
Bucket: bucket,
Key: key,
Expires: expires,
ContentType = 'application/octet-stream'
}
const s3 = new AWS.S3()
s3.getSignedUrl('putObject', params)
In my case I was using s3.getSignedUrl('getObject')
when I needed to be using s3.getSignedUrl('putObject')
(because I'm using a PUT to upload my file), which is why the signatures didn't match.
I had to set
Aws.config.update({
credentials: Aws::Credentials.new(access_key_id, secret_access_key)
})
before with the ruby aws sdk v2 (there is probably something similiar to this in the other languages as well)
I don't know if anyone came to this issue while trying to test the outputted URL in browser but if you are using Postman
and try to copy the generated url of AWS from the RAW
tab, because of escaping backslashes you are going to get the above error.
Use the Pretty
tab to copy and paste the url to see if it actually works.
I run into this issue recently and this solution solved my issue. It's for testing purposes to see if you actually retrieve the data through the url.
This answer is a reference to those who try to generate a download, temporary link from AWS or generally generate a URL from AWS to use.
I get this error with the wrong credentials. I think there were invisible characters when I pasted it originally.