mirror of
https://github.com/versity/versitygw.git
synced 2026-09-19 14:34:19 +00:00
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:
@@ -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,
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user