From b57db108146dfe91ed88736aa1317389fd90bd11 Mon Sep 17 00:00:00 2001 From: Kent Delante Date: Tue, 11 Nov 2025 13:14:55 +0800 Subject: [PATCH] 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 --- apps/files_external/lib/Lib/Storage/AmazonS3.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php index 5dc9e11453213..1e834811bd18f 100644 --- a/apps/files_external/lib/Lib/Storage/AmazonS3.php +++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php @@ -263,13 +263,16 @@ private function batchDelete(?string $path = null): bool { // 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();