Compare commits
No commits in common. "4a37a5aa147fceffcc35ebc5e7750a3946d812fd" and "b09f25cf3b8b2d5dcf468b02484436189ff7e25e" have entirely different histories.
4a37a5aa14
...
b09f25cf3b
@ -1,36 +0,0 @@
|
||||
package oss
|
||||
|
||||
import (
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||
)
|
||||
|
||||
type GetApkVersionRequest struct {
|
||||
*requests.JsonRequest
|
||||
Filepath string `position:"Body" field:"filepath"`
|
||||
}
|
||||
|
||||
type GetApkVersionResponse struct {
|
||||
*responses.BaseResponse
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data struct {
|
||||
VersionCode string `json:"versionCode"`
|
||||
VersionName string `json:"versionName"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
func CreateGetApkVersionRequest() (req *GetApkVersionRequest) {
|
||||
req = &GetApkVersionRequest{
|
||||
JsonRequest: &requests.JsonRequest{},
|
||||
}
|
||||
req.InitWithApiInfo(HOST, VERSION, "/api/apk/version")
|
||||
req.Method = requests.POST
|
||||
return
|
||||
}
|
||||
|
||||
func CreateGetApkVersionResponse() *GetApkVersionResponse {
|
||||
return &GetApkVersionResponse{
|
||||
BaseResponse: &responses.BaseResponse{},
|
||||
}
|
||||
}
|
@ -3,8 +3,6 @@ package oss
|
||||
import (
|
||||
"errors"
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/auth"
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/auth/credentials"
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||
)
|
||||
|
||||
@ -26,10 +24,6 @@ func NewClient() (client *Client, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func NewClientWithSts() {
|
||||
|
||||
}
|
||||
|
||||
func (c *Client) PutOss(req *PutOssRequest) (resp *PutOssResponse, err error) {
|
||||
if req.BucketName == "" {
|
||||
err = errors.New("bucket name is empty")
|
||||
@ -50,16 +44,3 @@ func (c *Client) DelOss(req *DelOssRequest) (resp *DelOssResponse, err error) {
|
||||
err = c.DoAction(req, resp)
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Client) InitMultipartUpload(req *InitMultipartUploadRequest) (resp *InitMultipartUploadResponse, err error) {
|
||||
resp = CreateInitMultipartUploadResponse()
|
||||
err = c.DoAction(req, resp)
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Client) GetApkVersion(req *GetApkVersionRequest) (resp *GetApkVersionResponse, err error) {
|
||||
resp = CreateGetApkVersionResponse()
|
||||
sign, err := auth.NewSignerWithCredential(credentials.NewStsTokenCredential("", "ccc", ""), nil)
|
||||
err = c.DoActionWithSigner(req, resp, sign)
|
||||
return
|
||||
}
|
||||
|
@ -39,37 +39,3 @@ func TestUpload_Del(t *testing.T) {
|
||||
}
|
||||
t.Log(resp.Code)
|
||||
}
|
||||
|
||||
func TestCreateInitMultipartUpload(t *testing.T) {
|
||||
req := CreateInitMultipartUploadRequest()
|
||||
req.Filepath = "test.jpg"
|
||||
req.TargetType = "oss"
|
||||
req.TargetName = "image"
|
||||
client, err := NewClient()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
resp, err := client.InitMultipartUpload(req)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
t.Log(resp)
|
||||
}
|
||||
|
||||
func TestClient_GetApkVersion(t *testing.T) {
|
||||
req := CreateGetApkVersionRequest()
|
||||
req.Filepath = "36c55c4c3a2f4c79e3917b989d580496.zip"
|
||||
client, err := NewClient()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
resp, err := client.GetApkVersion(req)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
t.Log(resp.Data.VersionCode, resp.Data.VersionName)
|
||||
}
|
||||
|
@ -1,58 +0,0 @@
|
||||
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"`
|
||||
} `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
|
||||
}
|
Loading…
Reference in New Issue
Block a user