fix: pass only necessary information when deleting mulitple objects

DeleteObjects currently fails when the request includes all the
information returned by ListObjects. Send only the necessary
information in the request. Note: 'Size' and 'DateModified' is now
only supported by directory buckets.

Signed-off-by: Kent Delante <kent.delante@proton.me>
This commit is contained in:
Kent Delante 2025-11-11 13:14:55 +08:00
parent 83a0e8a7a5
commit b57db10814

View file

@ -263,13 +263,16 @@ class AmazonS3 extends Common {
// to delete all objects prefixed with the path.
do {
// instead of the iterator, manually loop over the list ...
$objects = $connection->listObjects($params);
$objects = $connection->listObjectsV2($params);
// ... so we can delete the files in batches
if (isset($objects['Contents'])) {
$connection->deleteObjects([
'Bucket' => $this->bucket,
'Delete' => [
'Objects' => $objects['Contents']
'Objects' => array_map(fn (array $object) => [
'ETag' => $object['ETag'],
'Key' => $object['Key'],
], $objects['Contents'])
]
]);
$this->testTimeout();