2
我想用aws-sdk-php重命名S3上的圖像。 我的代碼如下:如何使用aws-sdk-php連接到amazon aws s3?
<?php
use Aws\S3\S3Client;
require 'aws-autoloader.php';
$client = S3Client::factory(array(
'credentials' => array(
'key' => 'mykey',
'secret' => 'mysecret',
),
'signature' => 'v4',
'region' => 'eu-central-1',
'version' => 'latest',
'http' => [
'verify' => false
]
));
$result = $client->copyObject(array(
'ACL' => 'private',
// Bucket is required
'Bucket' => 'myfirstbucket',
'Key' => "newfoldername/newimagename",
'CopySource' => "myfirstbucket/foldername/imagename",
'MetadataDirective' => 'REPLACE'
));
?>
我得到的錯誤是:
AWS HTTP error: Client error: 400 AuthorizationHeaderMalformed (client): The authorization header is malformed; the Credential is mal-formed; expecting \"\/YYYYMMDD\/REGION\/SERVICE\/aws4_request\"
有人可以幫助我嗎?
thx爲(某種程度上晚)的答案。由於此項目已經過時,我無法再驗證您的答案。但我會接受這個答案,因爲它聽起來很符合邏輯:-) – cari