From ddd137d31769185e6de4f27dfaba8de6498bb1ea Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Thu, 19 Dec 2024 10:21:46 -0800 Subject: [PATCH] ListObjectParts should return actual size (#20782) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #20781: ``` λ aws --endpoint-url http://127.0.0.1:9001 s3api list-parts --bucket testbucket --key test.testcompress --upload-id "ZDM0YzUwM2YtZWM1Zi00NWI2LTgxMzYtZTIwMGE3Yjc0Y2Y1LjYyMzgyMmFhLWU2N2QtNGUyYS04NDE1LWUzZDFlZmJmMWUyZHgxNzM0NjI1MjgyMDkyNzY4MDAw" { "Parts": [ { "PartNumber": 1, "LastModified": "2024-12-19T16:47:04.334000+00:00", "ETag": "\"7025f242f56479e06c435c0b500cdbb2\"", "Size": 2002 } ], "ChecksumAlgorithm": "", "Initiator": { "ID": "02d6176db174dc93cb1b899f7c6078f08654445fe8cf1b6ce98d8855f66bdbf4", "DisplayName": "02d6176db174dc93cb1b899f7c6078f08654445fe8cf1b6ce98d8855f66bdbf4" }, "Owner": { "DisplayName": "02d6176db174dc93cb1b899f7c6078f08654445fe8cf1b6ce98d8855f66bdbf4", "ID": "02d6176db174dc93cb1b899f7c6078f08654445fe8cf1b6ce98d8855f66bdbf4" }, "StorageClass": "STANDARD" } ``` (for whatever reason the python script generated a 2002 byte file ;) --- cmd/object-multipart-handlers.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/object-multipart-handlers.go b/cmd/object-multipart-handlers.go index d32ad30d4..bd0c01684 100644 --- a/cmd/object-multipart-handlers.go +++ b/cmd/object-multipart-handlers.go @@ -1204,6 +1204,10 @@ func (api objectAPIHandlers) ListObjectPartsHandler(w http.ResponseWriter, r *ht listPartsInfo.Parts[i].ETag = tryDecryptETag(objectEncryptionKey, p.ETag, kind == crypto.S3) listPartsInfo.Parts[i].Size = p.ActualSize } + } else if _, ok := listPartsInfo.UserDefined[ReservedMetadataPrefix+"compression"]; ok { + for i, p := range listPartsInfo.Parts { + listPartsInfo.Parts[i].Size = p.ActualSize + } } response := generateListPartsResponse(listPartsInfo, encodingType)