From 3e5d34dd6723a0e086e3964d2c6c252139e1c0d9 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sun, 18 Jan 2026 15:04:56 -0800 Subject: [PATCH] skip md5 validation if Content-MD5 is not provided --- weed/storage/needle/needle_parse_upload.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/weed/storage/needle/needle_parse_upload.go b/weed/storage/needle/needle_parse_upload.go index 6fadd80d6..5dd419b25 100644 --- a/weed/storage/needle/needle_parse_upload.go +++ b/weed/storage/needle/needle_parse_upload.go @@ -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