这是我正在使用的代码:
//AWS
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
S3_removeFilesFromWebsite('010101');
function s3_setClient() {
// Instantiate the client.
$s3 = new S3Client([
//"profile" => "default",
'version' => 'latest',
"region" => "us-east-1",
"http" => [
'verify' => false
],
'credentials' => [
'key' => $GLOBALS["s3bucket_key"],
'secret' => $GLOBALS["s3bucket_secret"],
],
]);
return $s3;
}
function S3_removeFilesFromWebsite($ID) {
$from_keyname = 'uploads/'.$ID.'/';
$uniqueFileName = '77';
$regexToDelete = "/.*".$uniqueFileName.".*/";
$s3 = s3_setClient();
$result = $s3->deleteMatchingObjects($GLOBALS["s3bucket"], $from_keyname, $regexToDelete);
}
这是我不断得到的错误:
<b>Type:</b> exception 'Aws\S3\Exception\DeleteMultipleObjectsException' with message 'Unable to delete certain keys when executing a DeleteMultipleObjects request:
- {"Key":"uploads\/010101\/77.csv","Code":"AccessDenied","Message":"Access Denied"}
- {"Key":"uploads\/010101\/43434\/77.csv","Code":"AccessDenied","Message":"Access Denied"}' in /Users/vendor/aws/aws-sdk-php/src/S3/BatchDelete.php:200
enter code here