mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00: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 (
|
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…
Reference in a new issue