Browse Source

volume: following md5 base64 encoding

fix https://github.com/chrislusf/seaweedfs/issues/1374
pull/1377/head
Chris Lu 5 years ago
parent
commit
20d9cfae86
  1. 3
      weed/storage/needle/needle_parse_upload.go

3
weed/storage/needle/needle_parse_upload.go

@ -2,6 +2,7 @@ package needle
import ( import (
"crypto/md5" "crypto/md5"
"encoding/base64"
"fmt" "fmt"
"io" "io"
"io/ioutil" "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 != "" { if expectedChecksum := r.Header.Get("Content-MD5"); expectedChecksum != "" {
h := md5.New() h := md5.New()
h.Write(pu.UncompressedData) 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) e = fmt.Errorf("Content-MD5 did not match md5 of file data [%s] != [%s]", expectedChecksum, receivedChecksum)
return return
} }

Loading…
Cancel
Save