From 20d9cfae861ea36d759d796f6f80345c01921ca6 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sun, 28 Jun 2020 07:25:50 -0700 Subject: [PATCH] volume: following md5 base64 encoding fix https://github.com/chrislusf/seaweedfs/issues/1374 --- weed/storage/needle/needle_parse_upload.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/weed/storage/needle/needle_parse_upload.go b/weed/storage/needle/needle_parse_upload.go index 10bef603f..785217761 100644 --- a/weed/storage/needle/needle_parse_upload.go +++ b/weed/storage/needle/needle_parse_upload.go @@ -2,6 +2,7 @@ package needle import ( "crypto/md5" + "encoding/base64" "fmt" "io" "io/ioutil" @@ -85,7 +86,7 @@ func ParseUpload(r *http.Request, sizeLimit int64) (pu *ParsedUpload, e error) { if expectedChecksum := r.Header.Get("Content-MD5"); expectedChecksum != "" { h := md5.New() h.Write(pu.UncompressedData) - if receivedChecksum := fmt.Sprintf("%x", h.Sum(nil)); expectedChecksum != receivedChecksum { + if receivedChecksum := base64.StdEncoding.EncodeToString(h.Sum(nil)); expectedChecksum != receivedChecksum { e = fmt.Errorf("Content-MD5 did not match md5 of file data [%s] != [%s]", expectedChecksum, receivedChecksum) return }