From 9eb94fe8c88a32f1d2cbfc167891db28baf90edc Mon Sep 17 00:00:00 2001 From: Nitish Tiwari Date: Thu, 5 Apr 2018 23:26:28 +0530 Subject: [PATCH] Fix StorageClass field in ListObject/ListObjectV2 response (#5766) Fixes: #5754 --- cmd/api-response.go | 4 ++-- cmd/object-api-datatypes.go | 3 +++ cmd/xl-v1-metadata.go | 7 +++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cmd/api-response.go b/cmd/api-response.go index b252616e5..6b528e762 100644 --- a/cmd/api-response.go +++ b/cmd/api-response.go @@ -339,7 +339,7 @@ func generateListObjectsV1Response(bucket, prefix, marker, delimiter string, max content.ETag = "\"" + object.ETag + "\"" } content.Size = object.Size - content.StorageClass = globalMinioDefaultStorageClass + content.StorageClass = object.StorageClass content.Owner = owner contents = append(contents, content) } @@ -385,7 +385,7 @@ func generateListObjectsV2Response(bucket, prefix, token, nextToken, startAfter, content.ETag = "\"" + object.ETag + "\"" } content.Size = object.Size - content.StorageClass = globalMinioDefaultStorageClass + content.StorageClass = object.StorageClass content.Owner = owner contents = append(contents, content) } diff --git a/cmd/object-api-datatypes.go b/cmd/object-api-datatypes.go index feb4a77d9..976c11272 100644 --- a/cmd/object-api-datatypes.go +++ b/cmd/object-api-datatypes.go @@ -98,6 +98,9 @@ type ObjectInfo struct { // by the Content-Type header field. ContentEncoding string + // Specify object storage class + StorageClass string + // User-Defined metadata UserDefined map[string]string diff --git a/cmd/xl-v1-metadata.go b/cmd/xl-v1-metadata.go index c33b5e1a3..362b2166f 100644 --- a/cmd/xl-v1-metadata.go +++ b/cmd/xl-v1-metadata.go @@ -315,6 +315,13 @@ func (m xlMetaV1) ToObjectInfo(bucket, object string) ObjectInfo { // All the parts per object. objInfo.Parts = m.Parts + // Update storage class + if sc, ok := m.Meta[amzStorageClass]; ok { + objInfo.StorageClass = sc + } else { + objInfo.StorageClass = globalMinioDefaultStorageClass + } + // Success. return objInfo }