use MD5 for ETag to be consistent with Amazon S3

This commit is contained in:
Chris Lu
2018-11-08 21:41:02 -08:00
parent 6e53c38c2f
commit a4ceb051a7
4 changed files with 51 additions and 6 deletions

View File

@@ -2,8 +2,9 @@ package storage
import (
"fmt"
"github.com/klauspost/crc32"
"crypto/md5"
"github.com/klauspost/crc32"
"github.com/chrislusf/seaweedfs/weed/util"
)
@@ -28,3 +29,13 @@ func (n *Needle) Etag() string {
util.Uint32toBytes(bits, uint32(n.Checksum))
return fmt.Sprintf("%x", bits)
}
func (n *Needle) MD5() string {
hash := md5.New()
hash.Write(n.Data)
return fmt.Sprintf("%x", hash.Sum(nil))
}