|
|
|
@ -83,11 +83,11 @@ func ParseUpload(r *http.Request, sizeLimit int64, bytesBuffer *bytes.Buffer) (p |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// md5
|
|
|
|
h := md5.New() |
|
|
|
h.Write(pu.UncompressedData) |
|
|
|
pu.ContentMd5 = base64.StdEncoding.EncodeToString(h.Sum(nil)) |
|
|
|
// verify Content-MD5
|
|
|
|
if expectedChecksum := r.Header.Get("Content-MD5"); expectedChecksum != "" { |
|
|
|
h := md5.New() |
|
|
|
h.Write(pu.UncompressedData) |
|
|
|
pu.ContentMd5 = base64.StdEncoding.EncodeToString(h.Sum(nil)) |
|
|
|
if expectedChecksum != pu.ContentMd5 { |
|
|
|
e = fmt.Errorf("Content-MD5 did not match md5 of file data expected [%s] received [%s] size %d", expectedChecksum, pu.ContentMd5, len(pu.UncompressedData)) |
|
|
|
return |
|
|
|
|