From e26c54c47462a21d3cdff036cbb0488f503de358 Mon Sep 17 00:00:00 2001 From: yuxh Date: Sat, 12 Oct 2024 15:27:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=88=86=E7=89=87=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E5=88=9D=E5=A7=8B=E5=8C=96=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sdk/requests/json_request.go | 6 +++++- services/oss/client_test.go | 8 +++++++- services/oss/multipart_init.go | 6 ++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/sdk/requests/json_request.go b/sdk/requests/json_request.go index d05de34..4e6b866 100644 --- a/sdk/requests/json_request.go +++ b/sdk/requests/json_request.go @@ -40,7 +40,11 @@ func (request *JsonRequest) GetStyle() string { func (request *JsonRequest) BuildQueries() string { path := strings.TrimLeft(strings.TrimSpace(request.GetActionName()), "/") - request.queries = "/" + path + "?" + utils.GetUrlFormedMap(request.QueryParams) + mod := "&" + if !strings.Contains(path, "?") { + mod = "?" + } + request.queries = "/" + path + mod + utils.GetUrlFormedMap(request.QueryParams) return request.queries } diff --git a/services/oss/client_test.go b/services/oss/client_test.go index daafc0a..e9d37fa 100644 --- a/services/oss/client_test.go +++ b/services/oss/client_test.go @@ -43,10 +43,16 @@ func TestUpload_Del(t *testing.T) { func TestCreateInitMultipartUpload(t *testing.T) { req := CreateInitMultipartUploadRequest() - req.Filepath = "test.jpg" + + extInfo := map[string]any{"game_byname": "tech_test_tencent"} + bExtInfo, _ := json.Marshal(extInfo) + + req.UploadType = "package" req.TargetType = "oss" req.TargetName = "image" req.FileHash = "51c68615b8d21f9b72b02f48c400cb87" + req.Filepath = "q5-01.zip" + req.ExtInfo = string(bExtInfo) client, err := NewClient() if err != nil { t.Error(err) diff --git a/services/oss/multipart_init.go b/services/oss/multipart_init.go index afb18a6..1d0c94d 100644 --- a/services/oss/multipart_init.go +++ b/services/oss/multipart_init.go @@ -15,10 +15,12 @@ const ( type InitMultipartUploadRequest struct { *requests.JsonRequest - Filepath string `position:"Body" field:"filepath"` + UploadType string `position:"Body" field:"upload_type"` TargetType string `position:"Body" field:"target_type"` TargetName string `position:"Body" field:"target_name"` FileHash string `position:"Body" field:"file_hash"` + Filepath string `position:"Body" field:"filepath"` + ExtInfo string `position:"Body" field:"ext_info"` } type InitMultipartUploadResponse struct { @@ -50,7 +52,7 @@ func CreateInitMultipartUploadRequest() (req *InitMultipartUploadRequest) { JsonRequest: &requests.JsonRequest{}, } - req.InitWithApiInfo(HOST, VERSION, "/api/upload/multipart/init?ts="+ts+"&sign="+sign) + req.InitWithApiInfo(HOST, VERSION, "/api/upload/multipart/init?_ts="+ts+"&_sign="+sign) return }