[#225] Add default storage class to responses

Signed-off-by: Marina Biryukova <m.biryukova@yadro.com>
This commit is contained in:
Marina Biryukova 2023-10-25 14:49:39 +03:00 committed by Alexey Vanin
parent 0938d7ee82
commit cf13aae342
6 changed files with 18 additions and 9 deletions

View file

@ -187,7 +187,7 @@ func encodeToObjectAttributesResponse(info *data.ObjectInfo, p *GetObjectAttribu
case eTag: case eTag:
resp.ETag = info.HashSum resp.ETag = info.HashSum
case storageClass: case storageClass:
resp.StorageClass = "STANDARD" resp.StorageClass = api.DefaultStorageClass
case objectSize: case objectSize:
resp.ObjectSize = info.Size resp.ObjectSize = info.Size
case checksum: case checksum:

View file

@ -98,6 +98,7 @@ func writeHeaders(h http.Header, requestHeader http.Header, extendedInfo *data.E
h.Set(api.ETag, info.ETag(md5Enabled)) h.Set(api.ETag, info.ETag(md5Enabled))
h.Set(api.AmzTaggingCount, strconv.Itoa(tagSetLength)) h.Set(api.AmzTaggingCount, strconv.Itoa(tagSetLength))
h.Set(api.AmzStorageClass, api.DefaultStorageClass)
if !isBucketUnversioned { if !isBucketUnversioned {
h.Set(api.AmzVersionID, extendedInfo.Version()) h.Set(api.AmzVersionID, extendedInfo.Version())

View file

@ -61,7 +61,7 @@ type (
Owner Owner `xml:"Owner"` Owner Owner `xml:"Owner"`
Parts []*layer.Part `xml:"Part"` Parts []*layer.Part `xml:"Part"`
PartNumberMarker int `xml:"PartNumberMarker,omitempty"` PartNumberMarker int `xml:"PartNumberMarker,omitempty"`
StorageClass string `xml:"StorageClass,omitempty"` StorageClass string `xml:"StorageClass"`
UploadID string `xml:"UploadId"` UploadID string `xml:"UploadId"`
} }
@ -70,7 +70,7 @@ type (
Initiator Initiator `xml:"Initiator"` Initiator Initiator `xml:"Initiator"`
Key string `xml:"Key"` Key string `xml:"Key"`
Owner Owner `xml:"Owner"` Owner Owner `xml:"Owner"`
StorageClass string `xml:"StorageClass,omitempty"` StorageClass string `xml:"StorageClass"`
UploadID string `xml:"UploadId"` UploadID string `xml:"UploadId"`
} }
@ -697,7 +697,8 @@ func encodeListMultipartUploadsToResponse(info *layer.ListMultipartUploadsInfo,
ID: u.Owner.String(), ID: u.Owner.String(),
DisplayName: u.Owner.String(), DisplayName: u.Owner.String(),
}, },
UploadID: u.UploadID, UploadID: u.UploadID,
StorageClass: api.DefaultStorageClass,
} }
uploads = append(uploads, m) uploads = append(uploads, m)
} }
@ -726,6 +727,7 @@ func encodeListPartsToResponse(info *layer.ListPartsInfo, params *layer.ListPart
PartNumberMarker: params.PartNumberMarker, PartNumberMarker: params.PartNumberMarker,
UploadID: params.Info.UploadID, UploadID: params.Info.UploadID,
Parts: info.Parts, Parts: info.Parts,
StorageClass: api.DefaultStorageClass,
} }
} }

View file

@ -6,6 +6,7 @@ import (
"strconv" "strconv"
"time" "time"
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api"
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/data" "git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/data"
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/errors" "git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/errors"
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/layer" "git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/layer"
@ -196,6 +197,7 @@ func fillContents(src []*data.ObjectInfo, encode string, fetchOwner bool) []Obje
Size: obj.Size, Size: obj.Size,
LastModified: obj.Created.UTC().Format(time.RFC3339), LastModified: obj.Created.UTC().Format(time.RFC3339),
ETag: obj.HashSum, ETag: obj.HashSum,
StorageClass: api.DefaultStorageClass,
} }
if size, err := layer.GetObjectSize(obj); err == nil { if size, err := layer.GetObjectSize(obj); err == nil {
@ -284,9 +286,10 @@ func encodeListObjectVersionsToResponse(info *layer.ListObjectVersionsInfo, buck
ID: ver.ObjectInfo.Owner.String(), ID: ver.ObjectInfo.Owner.String(),
DisplayName: ver.ObjectInfo.Owner.String(), DisplayName: ver.ObjectInfo.Owner.String(),
}, },
Size: ver.ObjectInfo.Size, Size: ver.ObjectInfo.Size,
VersionID: ver.Version(), VersionID: ver.Version(),
ETag: ver.ObjectInfo.ETag(md5Enabled), ETag: ver.ObjectInfo.ETag(md5Enabled),
StorageClass: api.DefaultStorageClass,
}) })
} }
// this loop is not starting till versioning is not implemented // this loop is not starting till versioning is not implemented

View file

@ -110,7 +110,7 @@ type Object struct {
Owner *Owner `xml:"Owner,omitempty"` Owner *Owner `xml:"Owner,omitempty"`
// Class of storage used to store the object. // Class of storage used to store the object.
StorageClass string `xml:"StorageClass,omitempty"` StorageClass string `xml:"StorageClass"`
} }
// ObjectVersionResponse container for object version in the response of ListBucketObjectVersionsHandler. // ObjectVersionResponse container for object version in the response of ListBucketObjectVersionsHandler.
@ -121,7 +121,7 @@ type ObjectVersionResponse struct {
LastModified string `xml:"LastModified"` LastModified string `xml:"LastModified"`
Owner Owner `xml:"Owner"` Owner Owner `xml:"Owner"`
Size uint64 `xml:"Size"` Size uint64 `xml:"Size"`
StorageClass string `xml:"StorageClass,omitempty"` // is empty!! StorageClass string `xml:"StorageClass"`
VersionID string `xml:"VersionId"` VersionID string `xml:"VersionId"`
} }

View file

@ -61,6 +61,7 @@ const (
AmzObjectAttributes = "X-Amz-Object-Attributes" AmzObjectAttributes = "X-Amz-Object-Attributes"
AmzMaxParts = "X-Amz-Max-Parts" AmzMaxParts = "X-Amz-Max-Parts"
AmzPartNumberMarker = "X-Amz-Part-Number-Marker" AmzPartNumberMarker = "X-Amz-Part-Number-Marker"
AmzStorageClass = "X-Amz-Storage-Class"
AmzServerSideEncryptionCustomerAlgorithm = "x-amz-server-side-encryption-customer-algorithm" AmzServerSideEncryptionCustomerAlgorithm = "x-amz-server-side-encryption-customer-algorithm"
AmzServerSideEncryptionCustomerKey = "x-amz-server-side-encryption-customer-key" AmzServerSideEncryptionCustomerKey = "x-amz-server-side-encryption-customer-key"
@ -89,6 +90,8 @@ const (
DefaultLocationConstraint = "default" DefaultLocationConstraint = "default"
StreamingContentSHA256 = "STREAMING-AWS4-HMAC-SHA256-PAYLOAD" StreamingContentSHA256 = "STREAMING-AWS4-HMAC-SHA256-PAYLOAD"
DefaultStorageClass = "STANDARD"
) )
// S3 request query params. // S3 request query params.