jeudi 29 janvier 2015

Amazon S3 PHP SDK pre-signed requests

I am trying to generate a presigned request with the S3 PHP SDK like this:



$s3Client = Aws\S3\S3Client::factory([
'credentials' => new Aws\Common\Credentials\Credentials('my-access-code', 'xxx')
]);

$command = $s3Client->getCommand('GetObject', [
'Bucket' => 'my-bucket-name',
'Key' => 'awesome-cat-image.png',
]);

$signedUrl = $command->createPresignedUrl('+10 minutes');


But when I goto the URL I get an error saying:



<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>xxx</AWSAccessKeyId>
<StringToSign>GET 1422564095 /my-bucket-name/awesome-cat-image.png</StringToSign>
<SignatureProvided>xxx</SignatureProvided>
<StringToSignBytes>
xxx
</StringToSignBytes>
<RequestId>xxx</RequestId>
<HostId>
xxx
</HostId>
</Error>


Accessing http://ift.tt/1JPs13g works just fine with permissions set to allow non authenticated users.





Aucun commentaire:

Enregistrer un commentaire