7
0

更新分片上传初始化接口

This commit is contained in:
余 欣怀 2024-10-12 15:27:57 +08:00
parent f272d5f199
commit e26c54c474
3 changed files with 16 additions and 4 deletions

View File

@ -40,7 +40,11 @@ func (request *JsonRequest) GetStyle() string {
func (request *JsonRequest) BuildQueries() string { func (request *JsonRequest) BuildQueries() string {
path := strings.TrimLeft(strings.TrimSpace(request.GetActionName()), "/") 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 return request.queries
} }

View File

@ -43,10 +43,16 @@ func TestUpload_Del(t *testing.T) {
func TestCreateInitMultipartUpload(t *testing.T) { func TestCreateInitMultipartUpload(t *testing.T) {
req := CreateInitMultipartUploadRequest() 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.TargetType = "oss"
req.TargetName = "image" req.TargetName = "image"
req.FileHash = "51c68615b8d21f9b72b02f48c400cb87" req.FileHash = "51c68615b8d21f9b72b02f48c400cb87"
req.Filepath = "q5-01.zip"
req.ExtInfo = string(bExtInfo)
client, err := NewClient() client, err := NewClient()
if err != nil { if err != nil {
t.Error(err) t.Error(err)

View File

@ -15,10 +15,12 @@ const (
type InitMultipartUploadRequest struct { type InitMultipartUploadRequest struct {
*requests.JsonRequest *requests.JsonRequest
Filepath string `position:"Body" field:"filepath"` UploadType string `position:"Body" field:"upload_type"`
TargetType string `position:"Body" field:"target_type"` TargetType string `position:"Body" field:"target_type"`
TargetName string `position:"Body" field:"target_name"` TargetName string `position:"Body" field:"target_name"`
FileHash string `position:"Body" field:"file_hash"` FileHash string `position:"Body" field:"file_hash"`
Filepath string `position:"Body" field:"filepath"`
ExtInfo string `position:"Body" field:"ext_info"`
} }
type InitMultipartUploadResponse struct { type InitMultipartUploadResponse struct {
@ -50,7 +52,7 @@ func CreateInitMultipartUploadRequest() (req *InitMultipartUploadRequest) {
JsonRequest: &requests.JsonRequest{}, 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 return
} }