Reputation: 174
trying to upload file using presigned URL and tried all the solution from stackoverflow but didn't worked for me. Lambda has full access of S3 not seems to be key issue but getting following error:
<Error>
<Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>
<AWSAccessKeyId>AKIAZRFKVHH444H7KZHN</AWSAccessKeyId>
<StringToSign>AWS4-HMAC-SHA256
Find the code I tried:
xsdfileurl= s3_con.generate_presigned_url(
ClientMethod='put_object',
Params={
'Bucket': event["Bucketname"],
'Key': "{}/{}".format("CR001CN001/1", event["Files"][0]),
},
ExpiresIn=6000)
print(xsdfileurl)
Any help will be appreciated.
Upvotes: 0
Views: 463
Reputation: 174
I myself wasted whole day in getting the root cause and found one silly mistake that the CORS configuration was missing in bucket.
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
Upvotes: 1