public function deleteDirectory(string
$path): void
{ $prefix =
$this->prefixer->
prefixDirectoryPath($path);
$prefix =
ltrim($prefix, '/'
);
$objects =
[];
$params =
['Bucket' =>
$this->bucket, 'Prefix' =>
$prefix];
$result =
$this->client->
listObjectsV2($params);
/** @var AwsObject $item */
foreach ($result->
getContents() as $item) { $key =
$item->
getKey();
if ($key !== null
) { $objects[] =
new ObjectIdentifier(['Key' =>
$key]);
} } if (empty($objects)) { return;
} foreach (array_chunk($objects, 1000
) as $chunk) { $this->client->
deleteObjects([ 'Bucket' =>
$this->bucket,
'Delete' =>
['Objects' =>
$chunk],
]);
}