feat: adds x-amz-object-size in PutObject response headers

Closes #1518

Adds the `x-amz-object-size` header to the `PutObject` response, indicating the size of the uploaded object. This change is applied to the POSIX, Azure, and S3 proxy backends.
This commit is contained in:
niksis02
2025-09-05 21:40:46 +04:00
parent 743707b9ae
commit 818e91ebde
8 changed files with 47 additions and 2 deletions
+1
View File
@@ -725,6 +725,7 @@ func (c S3ApiController) PutObject(ctx *fiber.Ctx) (*Response, error) {
"x-amz-checksum-sha256": res.ChecksumSHA256,
"x-amz-checksum-type": utils.ConvertToStringPtr(res.ChecksumType),
"x-amz-version-id": &res.VersionID,
"x-amz-object-size": utils.ConvertPtrToStringPtr(res.Size),
},
MetaOpts: &MetaOptions{
ContentLength: contentLength,
+4
View File
@@ -1036,6 +1036,7 @@ func TestS3ApiController_CopyObject(t *testing.T) {
func TestS3ApiController_PutObject(t *testing.T) {
str := ""
emptyStringPtr := &str
objSize := int64(120)
tests := []struct {
name string
@@ -1148,6 +1149,7 @@ func TestS3ApiController_PutObject(t *testing.T) {
"x-amz-checksum-sha256": nil,
"x-amz-checksum-type": nil,
"x-amz-version-id": emptyStringPtr,
"x-amz-object-size": nil,
},
MetaOpts: &MetaOptions{
BucketOwner: "root",
@@ -1188,6 +1190,7 @@ func TestS3ApiController_PutObject(t *testing.T) {
ChecksumCRC64NVME: utils.GetStringPtr("crc64nvme"),
ChecksumType: types.ChecksumTypeComposite,
VersionID: "versionId",
Size: &objSize,
},
},
output: testOutput{
@@ -1201,6 +1204,7 @@ func TestS3ApiController_PutObject(t *testing.T) {
"x-amz-checksum-sha256": utils.GetStringPtr("sha256"),
"x-amz-checksum-type": utils.GetStringPtr(string(types.ChecksumTypeComposite)),
"x-amz-version-id": utils.GetStringPtr("versionId"),
"x-amz-object-size": utils.ConvertToStringPtr(objSize),
},
MetaOpts: &MetaOptions{
BucketOwner: "root",