2
私を助けてください!私はaws-php-sdkを使ってaws s3サーバー上のファイルをアップロードしています。サーバーからaws s3サーバーにフォルダを移動でき、ファイルを削除できますが、ディレクトリを作成できません/ 私は常にアクセス拒否エラーを受け取ります。PHP aws s3バケットにフォルダを作成するには?
エラーは、私は私の自己解決を考え出し
Error executing "PutObject" on "https://s3.amazonaws.com/***/***/***/picture/"; AWS HTTP error: Client error: `PUT https://s3.amazonaws.com/***/****/****/picture/` resulted in a `403 Forbidden` response: <?xml version="1.0" encoding="UTF-8"?> <Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>CE24E8 (truncated...) AccessDenied (client): Access Denied - <?xml version="1.0" encoding="UTF-8"?> <Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>CE24E8FFC9216978</RequestId><HostId>DHdN6tcopPTP9IsVu/qGWClf1+hAoWv7CNUWJRsOPWia4SfQYQ+VPYgJ3+vlqqRBNbYWB34gEQ0=</HostId></Error>
and here is my code
$s3Client = new Aws\S3\S3Client([
'version' => AWS_VERSION,
'region' => AWS_REGION,
'credentials' => [
'key' => AWS_KEY,
'secret' =>AWS_SECRET,
],
]);
//code to create the directory
$s3Client->putObject(array(
'Bucket' => AWS_BUCKET, // Defines name of Bucket
'Key' => "picture/", //Defines Folder name
'Body' => "",
'ACL' => 'public-read' // Defines Permission to that folder
));
//I have also used along with full AWS_PATH, that is my uploading direcctory path on the aws server but none of them is working always gets the same error.
$s3Client->putObject(array(
'Bucket' => AWS_BUCKET, // Defines name of Bucket
'Key' => AWS_PATH . "picture/", //Defines Folder name
'Body' => "",
'ACL' => 'public-read' // Defines Permission to that folder
));