PHP如何在aws s3 bucket中创建文件夹?

PHP如何在aws s3 bucket中创建文件夹?,php,amazon-s3,directory,storage,Php,Amazon S3,Directory,Storage,请帮帮我!我正在使用aws php sdk在aws s3服务器上上传一个文件。我可以将文件夹从服务器移动到aws s3服务器,可以删除文件,但无法创建目录/ 我总是遇到访问被拒绝的错误 错误是 Error executing "PutObject" on "https://s3.amazonaws.com/***/***/***/picture/"; AWS HTTP error: Client error: `PUT https://s3.amazonaws.com/***/****/****

请帮帮我!我正在使用aws php sdk在aws s3服务器上上传一个文件。我可以将文件夹从服务器移动到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
        ));

我自己想出了解决办法。 实际上,在创建新目录时,我不能授予新目录的权限,因为我不是bucket的所有者。我把水桶当作第三方使用。因此,我必须从代码中删除“ACL”=>“public-read”,现在我的代码是

 $s3Client->putObject(array(
            'Bucket' => AWS_BUCKET, // Defines name of Bucket
            'Key' => AWS_PATH . "picture/", //Defines Folder name
            'Body' => "",
        ));