mirror of
https://github.com/versity/versitygw.git
synced 2026-09-19 14:34:19 +00:00
feat: Added the standard storage class to all the available get/list actions responses in posix. (#765)
This commit is contained in:
+46
-35
@@ -419,56 +419,65 @@ func (c S3ApiController) GetActions(ctx *fiber.Ctx) error {
|
||||
})
|
||||
}
|
||||
|
||||
utils.SetMetaHeaders(ctx, res.Metadata)
|
||||
var lastmod string
|
||||
if res.LastModified != nil {
|
||||
lastmod = res.LastModified.Format(timefmt)
|
||||
}
|
||||
|
||||
contentType := getstring(res.ContentType)
|
||||
if contentType == "" {
|
||||
contentType = defaultContentType
|
||||
}
|
||||
acceptRanges := getstring(res.AcceptRanges)
|
||||
if acceptRanges == "" {
|
||||
acceptRanges = "bytes"
|
||||
}
|
||||
|
||||
utils.SetResponseHeaders(ctx, []utils.CustomHeader{
|
||||
hdrs := []utils.CustomHeader{
|
||||
{
|
||||
Key: "Content-Type",
|
||||
Value: contentType,
|
||||
},
|
||||
{
|
||||
Key: "Content-Encoding",
|
||||
Value: getstring(res.ContentEncoding),
|
||||
},
|
||||
{
|
||||
Key: "ETag",
|
||||
Value: getstring(res.ETag),
|
||||
},
|
||||
{
|
||||
Key: "Last-Modified",
|
||||
Value: lastmod,
|
||||
Key: "accept-ranges",
|
||||
Value: acceptRanges,
|
||||
},
|
||||
{
|
||||
Key: "x-amz-storage-class",
|
||||
Value: string(res.StorageClass),
|
||||
},
|
||||
{
|
||||
}
|
||||
|
||||
if getstring(res.ContentRange) != "" {
|
||||
hdrs = append(hdrs, utils.CustomHeader{
|
||||
Key: "Content-Range",
|
||||
Value: getstring(res.ContentRange),
|
||||
},
|
||||
{
|
||||
Key: "accept-ranges",
|
||||
Value: getstring(res.AcceptRanges),
|
||||
},
|
||||
})
|
||||
|
||||
if res.TagCount != nil {
|
||||
utils.SetResponseHeaders(ctx, []utils.CustomHeader{
|
||||
{
|
||||
Key: "x-amz-tagging-count",
|
||||
Value: fmt.Sprint(*res.TagCount),
|
||||
},
|
||||
})
|
||||
}
|
||||
if res.LastModified != nil {
|
||||
hdrs = append(hdrs, utils.CustomHeader{
|
||||
Key: "Last-Modified",
|
||||
Value: res.LastModified.Format(timefmt),
|
||||
})
|
||||
}
|
||||
if getstring(res.ContentEncoding) != "" {
|
||||
hdrs = append(hdrs, utils.CustomHeader{
|
||||
Key: "Content-Encoding",
|
||||
Value: getstring(res.ContentEncoding),
|
||||
})
|
||||
}
|
||||
if res.TagCount != nil {
|
||||
hdrs = append(hdrs, utils.CustomHeader{
|
||||
Key: "x-amz-tagging-count",
|
||||
Value: fmt.Sprint(*res.TagCount),
|
||||
})
|
||||
}
|
||||
if res.StorageClass != "" {
|
||||
hdrs = append(hdrs, utils.CustomHeader{
|
||||
Key: "x-amz-storage-class",
|
||||
Value: string(res.StorageClass),
|
||||
})
|
||||
}
|
||||
|
||||
// Set x-amz-meta-... headers
|
||||
utils.SetMetaHeaders(ctx, res.Metadata)
|
||||
// Set other response headers
|
||||
utils.SetResponseHeaders(ctx, hdrs)
|
||||
|
||||
status := http.StatusOK
|
||||
if acceptRange != "" {
|
||||
@@ -2751,10 +2760,6 @@ func (c S3ApiController) HeadObject(ctx *fiber.Ctx) error {
|
||||
Key: "ETag",
|
||||
Value: getstring(res.ETag),
|
||||
},
|
||||
{
|
||||
Key: "x-amz-storage-class",
|
||||
Value: string(res.StorageClass),
|
||||
},
|
||||
{
|
||||
Key: "x-amz-restore",
|
||||
Value: getstring(res.Restore),
|
||||
@@ -2798,6 +2803,12 @@ func (c S3ApiController) HeadObject(ctx *fiber.Ctx) error {
|
||||
Value: getstring(res.ContentEncoding),
|
||||
})
|
||||
}
|
||||
if res.StorageClass != "" {
|
||||
headers = append(headers, utils.CustomHeader{
|
||||
Key: "x-amz-storage-class",
|
||||
Value: string(res.StorageClass),
|
||||
})
|
||||
}
|
||||
|
||||
contentType := getstring(res.ContentType)
|
||||
if contentType == "" {
|
||||
|
||||
@@ -259,7 +259,7 @@ func FilterObjectAttributes(attrs map[types.ObjectAttributes]struct{}, output s3
|
||||
output.ObjectSize = nil
|
||||
}
|
||||
if _, ok := attrs[types.ObjectAttributesStorageClass]; !ok {
|
||||
output.StorageClass = nil
|
||||
output.StorageClass = ""
|
||||
}
|
||||
|
||||
return output
|
||||
|
||||
Reference in New Issue
Block a user