[#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 `<hash>` to `SHA256:<hash>` in latest update.

S3 gateway should not be relied on unstable string format
implementations and use raw value.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2022-05-12 19:58:11 +03:00 committed by Kira
parent 1c33f06bfe
commit b778c2e072
3 changed files with 6 additions and 3 deletions

View file

@ -2,6 +2,7 @@ package layer
import ( import (
"context" "context"
"encoding/hex"
"errors" "errors"
"fmt" "fmt"
"io" "io"
@ -260,7 +261,7 @@ func (n *layer) PutObject(ctx context.Context, p *PutObjectParams) (*data.Object
CreationEpoch: meta.CreationEpoch(), CreationEpoch: meta.CreationEpoch(),
Headers: p.Header, Headers: p.Header,
ContentType: p.Header[api.ContentType], ContentType: p.Header[api.ContentType],
HashSum: payloadChecksum.String(), HashSum: hex.EncodeToString(payloadChecksum.Value()),
}, nil }, nil
} }

View file

@ -2,6 +2,7 @@ package layer
import ( import (
"context" "context"
"encoding/hex"
"fmt" "fmt"
"os" "os"
"strconv" "strconv"
@ -126,7 +127,7 @@ func objectInfoFromMeta(bkt *data.BucketInfo, meta *object.Object, prefix, delim
Headers: userHeaders, Headers: userHeaders,
Owner: meta.OwnerID(), Owner: meta.OwnerID(),
Size: size, Size: size,
HashSum: payloadChecksum.String(), HashSum: hex.EncodeToString(payloadChecksum.Value()),
} }
} }

View file

@ -1,6 +1,7 @@
package layer package layer
import ( import (
"encoding/hex"
"net/http" "net/http"
"strconv" "strconv"
"testing" "testing"
@ -58,7 +59,7 @@ func newTestInfo(oid *oid.ID, bkt *data.BucketInfo, name string, isDir bool) *da
Created: time.Unix(defaultTestCreated.Unix(), 0), Created: time.Unix(defaultTestCreated.Unix(), 0),
Owner: bkt.Owner, Owner: bkt.Owner,
Headers: make(map[string]string), Headers: make(map[string]string),
HashSum: hashSum.String(), HashSum: hex.EncodeToString(hashSum.Value()),
} }
if isDir { if isDir {