From ad9137931b8b9787fc9896ab3afee6b89f7ab2a8 Mon Sep 17 00:00:00 2001 From: withchao <48119764+withchao@users.noreply.github.com> Date: Fri, 21 Jul 2023 22:37:54 +0800 Subject: [PATCH] fix: Compatible with wasm s3 oss header Date (#630) * fix: optimize minio initialization * test date * test date * test date * test date --- pkg/common/db/s3/oss/oss.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/common/db/s3/oss/oss.go b/pkg/common/db/s3/oss/oss.go index f689836c6..774150389 100644 --- a/pkg/common/db/s3/oss/oss.go +++ b/pkg/common/db/s3/oss/oss.go @@ -146,14 +146,17 @@ func (o *OSS) AuthSign(ctx context.Context, uploadID string, name string, expire if o.credentials.GetSecurityToken() != "" { request.Header.Set(oss.HTTPHeaderOssSecurityToken, o.credentials.GetSecurityToken()) } + now := time.Now().UTC().Format(http.TimeFormat) request.Header.Set(oss.HTTPHeaderHost, request.Host) - request.Header.Set(oss.HTTPHeaderDate, time.Now().UTC().Format(http.TimeFormat)) + request.Header.Set(oss.HTTPHeaderDate, now) + request.Header.Set(oss.HttpHeaderOssDate, now) authorization := fmt.Sprintf( `OSS %s:%s`, o.credentials.GetAccessKeyID(), o.getSignedStr(request, fmt.Sprintf(`/%s/%s?partNumber=%d&uploadId=%s`, o.bucket.BucketName, name, partNumber, uploadID), o.credentials.GetAccessKeySecret()), ) request.Header.Set(oss.HTTPHeaderAuthorization, authorization) + delete(request.Header, oss.HTTPHeaderDate) result.Parts[i] = s3.SignPart{ PartNumber: partNumber, Query: url.Values{"partNumber": {strconv.Itoa(partNumber)}}, @@ -275,5 +278,5 @@ func (o *OSS) AccessURL(ctx context.Context, name string, expire time.Duration, } else if expire < time.Second { expire = time.Second } - return o.bucket.SignURL(name, http.MethodGet, int64(expire/time.Second)) + return o.bucket.SignURL(name, http.MethodGet, int64(expire/time.Second), opts...) }