diff --git a/.github/workflows/test-s3-over-https-using-awscli.yml b/.github/workflows/test-s3-over-https-using-awscli.yml index f09d1c1aa..18d576ddf 100644 --- a/.github/workflows/test-s3-over-https-using-awscli.yml +++ b/.github/workflows/test-s3-over-https-using-awscli.yml @@ -77,3 +77,12 @@ jobs: aws --no-verify-ssl s3 cp --no-progress s3://bucket/test-multipart downloaded diff -q generated downloaded rm -f generated downloaded + + - name: Test GetObject with If-Match + run: | + set -e + dd if=/dev/urandom of=generated bs=1M count=32 + ETAG=$(aws --no-verify-ssl s3api put-object --bucket bucket --key test-get-obj --body generated | jq -r .ETag) + aws --no-verify-ssl s3api get-object --bucket bucket --key test-get-obj --if-match ${ETAG:1:32} downloaded + diff -q generated downloaded + rm -f downloaded diff --git a/weed/s3api/s3api_object_handlers_put.go b/weed/s3api/s3api_object_handlers_put.go index 17fceb8d2..e56e23780 100644 --- a/weed/s3api/s3api_object_handlers_put.go +++ b/weed/s3api/s3api_object_handlers_put.go @@ -1085,6 +1085,9 @@ func (s3a *S3ApiServer) getObjectETag(entry *filer_pb.Entry) string { if etagBytes, hasETag := entry.Extended[s3_constants.ExtETagKey]; hasETag { return string(etagBytes) } + if entry.Attributes.Md5 != nil { + return fmt.Sprintf("\"%x\"", entry.Attributes.Md5) + } // Fallback: calculate ETag from chunks return s3a.calculateETagFromChunks(entry.Chunks) }