问题
I am using a PHP class for Amazon S3 and CloudFront - Link. But when I try to upload a file into a bucket, I get this error:
[SignatureDoesNotMatch] The request signature we calculated does not match the signature you provided. Check your key and signing method.
How to fix it?
Thanks.
回答1:
When you sign up for Amazon, you can create yourself a key pair (Amazon calls those access key ID and secret access key).
Those two are used to sign requests to Amazon's webservices. Amazon re-calculates the signature and compares if it matches the one that was contained in your request. That way the secret access key never needs to be transmitted over the network.
If you get "Signature does not match", it's highly likely you used a wrong secret access key. Can you double-check access key and secret access key to make sure they're correct?
回答2:
Personally I received this error because of the characters that were in my meta data.
The problematic character was the "–" chracter which is "\u2013" in unicode and different to "-".
$result = $s3->putObject(array(
'Bucket' => $bucket,
'Key' => $keyname,
'Metadata' => [
'name' => 'Terminology – Blah'
]
));
A note from the documentation http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#UserMetadata...
Amazon S3 stores user-defined metadata in lowercase. Each name, value pair must conform to US-ASCII when using REST and UTF-8 when using SOAP or browser-based uploads via POST.
回答3:
I had this error with putObject()
when specifying a Key
starting with slash character (/
) - after removing the slash it worked fine.
来源:https://stackoverflow.com/questions/10281557/signaturedoesnotmatch-amazon-s3-api