package oss import ( "crypto/md5" "encoding/hex" "fmt" "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests" "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses" "time" ) const ( multipartUploadKeys = "b4471b940d98" ) type InitMultipartUploadRequest struct { *requests.JsonRequest Filepath string `position:"Body" field:"filepath"` TargetType string `position:"Body" field:"target_type"` TargetName string `position:"Body" field:"target_name"` FileHash string `position:"Body" field:"file_hash"` } type InitMultipartUploadResponse struct { *responses.BaseResponse Code int `json:"code"` Msg string `json:"msg"` Data struct { FileUploaded bool `json:"file_uploaded"` UploadId string `json:"upload_id,omitempty"` Links []Link `json:"links,omitempty"` Hash string `json:"hash,omitempty"` Url string `json:"url,omitempty"` Filepath string `json:"filepath,omitempty"` FileName string `json:"filename,omitempty"` } `json:"data"` } type Link struct { Href string `json:"href"` Rel string `json:"rel"` Method string `json:"method"` } func CreateInitMultipartUploadRequest() (req *InitMultipartUploadRequest) { ts := fmt.Sprintf("%d", time.Now().Unix()) m := md5.Sum([]byte(ts + multipartUploadKeys)) sign := hex.EncodeToString(m[:]) req = &InitMultipartUploadRequest{ JsonRequest: &requests.JsonRequest{}, } req.InitWithApiInfo(HOST, VERSION, "/api/upload/multipart/init?ts="+ts+"&sign="+sign) return } func CreateInitMultipartUploadResponse() (resp *InitMultipartUploadResponse) { resp = &InitMultipartUploadResponse{ BaseResponse: &responses.BaseResponse{}, } return resp }