From 70b6cd360deba38bccd7507f35d6db2221bf729e Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Mon, 10 Jul 2023 18:32:25 +0800 Subject: [PATCH] s3 presigned put --- pkg/common/db/s3/cont/controller.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/common/db/s3/cont/controller.go b/pkg/common/db/s3/cont/controller.go index 5645184dd..669be9267 100644 --- a/pkg/common/db/s3/cont/controller.go +++ b/pkg/common/db/s3/cont/controller.go @@ -187,7 +187,8 @@ func (c *Controller) CompleteUpload(ctx context.Context, uploadID string, partHa if uploadInfo.Size != upload.Size { return nil, errors.New("upload size mismatching") } - if uploadInfo.ETag != upload.Hash { + md5Sum := md5.Sum([]byte(strings.Join([]string{uploadInfo.ETag}, ","))) + if hex.EncodeToString(md5Sum[:]) != upload.Hash { return nil, errors.New("upload md5 mismatching") } // 防止在这个时候,并发操作,导致文件被覆盖