From b778c2e07244df02fa012f23e545236d3723c6a5 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Thu, 12 May 2022 19:58:11 +0300 Subject: [PATCH] [#431] Fix ETag value ETag is a string with SHA256 of NeoFS object payload. Hash is taken from object header by neofs-sdk-go getter. Checksum type in neofs-sdk-go has changes `String()` output from `` to `SHA256:` in latest update. S3 gateway should not be relied on unstable string format implementations and use raw value. Signed-off-by: Alex Vanin --- api/layer/object.go | 3 ++- api/layer/util.go | 3 ++- api/layer/util_test.go | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/api/layer/object.go b/api/layer/object.go index e50febbf..c522584c 100644 --- a/api/layer/object.go +++ b/api/layer/object.go @@ -2,6 +2,7 @@ package layer import ( "context" + "encoding/hex" "errors" "fmt" "io" @@ -260,7 +261,7 @@ func (n *layer) PutObject(ctx context.Context, p *PutObjectParams) (*data.Object CreationEpoch: meta.CreationEpoch(), Headers: p.Header, ContentType: p.Header[api.ContentType], - HashSum: payloadChecksum.String(), + HashSum: hex.EncodeToString(payloadChecksum.Value()), }, nil } diff --git a/api/layer/util.go b/api/layer/util.go index e3a1588c..f5a7c9c2 100644 --- a/api/layer/util.go +++ b/api/layer/util.go @@ -2,6 +2,7 @@ package layer import ( "context" + "encoding/hex" "fmt" "os" "strconv" @@ -126,7 +127,7 @@ func objectInfoFromMeta(bkt *data.BucketInfo, meta *object.Object, prefix, delim Headers: userHeaders, Owner: meta.OwnerID(), Size: size, - HashSum: payloadChecksum.String(), + HashSum: hex.EncodeToString(payloadChecksum.Value()), } } diff --git a/api/layer/util_test.go b/api/layer/util_test.go index 33de7838..5f8d78f1 100644 --- a/api/layer/util_test.go +++ b/api/layer/util_test.go @@ -1,6 +1,7 @@ package layer import ( + "encoding/hex" "net/http" "strconv" "testing" @@ -58,7 +59,7 @@ func newTestInfo(oid *oid.ID, bkt *data.BucketInfo, name string, isDir bool) *da Created: time.Unix(defaultTestCreated.Unix(), 0), Owner: bkt.Owner, Headers: make(map[string]string), - HashSum: hashSum.String(), + HashSum: hex.EncodeToString(hashSum.Value()), } if isDir {