mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-04-05 20:52:50 +08:00
volume: following md5 base64 encoding
fix https://github.com/chrislusf/seaweedfs/issues/1374
This commit is contained in:
parent
f0f884edd5
commit
20d9cfae86
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user