创建 Amazon aws s3 预签名 url PHP
根据这个链接 http://docs.aws.amazon.com/aws-sdk-php/v2/guide/service-s3.html,我可以很容易地创建一个预签名的链接,只需将生命周期添加到getObjectUrl
$signedUrl = $client->getObjectUrl($bucket, 'data.txt', '+10 minutes');
// > https://my-bucket.s3.amazonaws.com/data.txt?AWSAccessKeyId=[...]&Expires=[...]&Signature=[...]
但是我得到了一个普通的网址,你知道,没有awsaccesskeyid和过期参数,
这是我的代码:
$bucket = 'imagenesfc';
$keyname = 'NASimagenes/codigoBarraBoleto/1001000098.png';
$filepath = 'NASimagenes/codigoBarraBoleto';
// Instantiate the client.
$s3 = S3Client::factory(array(
'version' => 'latest',
'region' => 'us-west-1'
));
$signedUrl = $s3->getObjectUrl($bucket, $keyname,'+10 minutes');
// > https://my-bucket.s3.amazonaws.com/data.txt?AWSAccessKeyId=[...]&Expires=[...]&Signature=[...]
echo $signedUrl."<br>";
编辑:我有AWS_ACCESS_KEY_ID和AWS_SECRET_ACCESS_KEY作为环境变量
我的回声看起来像这样:
https://s3-us-west-1.amazonaws.com/imagenesfc/NASimagenes/codigoBarraBoleto/1001000098.png
怎么了?