我正在尝试集成PHP Amazon SDK - s3 api。我给出了正确的凭据。但我不确定putObject参数。 这是我试过的代码:
try {
$s3Client->putObject(array(
'Bucket' => $bucket,
'Key' => $filename,
'Body' => file_get_contents(drupal_realpath($file_path)),
'ACL' => 'public-read',
));
} catch (S3Exception $e) {echo '<pre>';print_r($e);
echo "There was an error uploading the file.\n";
}
exit;
发出请求后,我收到此回应:
Aws\S3\Exception\AccessDeniedException Object
(
[response:protected] => Guzzle\Http\Message\Response Object
(
[body:protected] => Guzzle\Http\EntityBody Object
(
[contentEncoding:protected] =>
[rewindFunction:protected] =>
[stream:protected] => Resource id #219
[size:protected] =>
[cache:protected] => Array
(
[wrapper_type] => PHP
[stream_type] => TEMP
[mode] => w+b
[unread_bytes] => 0
[seekable] => 1
[uri] => php://temp
[is_local] => 1
[is_readable] => 1
[is_writable] => 1
)
[customData:protected] => Array
(
)
)
[reasonPhrase:protected] => Forbidden
[statusCode:protected] => 403
[info:protected] => Array
(
[url] => https://s3.amazonaws.com/my_test/ak1.jpg
[content_type] => application/xml
[http_code] => 403
[header_size] => 273
[request_size] => 320
[filetime] => -1
.........................................................................................................