7
0
gaore-common-sdk-go/services/oss/client.go

66 lines
1.5 KiB
Go
Raw Permalink Normal View History

2024-05-30 18:40:57 +08:00
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"
2024-05-30 18:40:57 +08:00
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
)
const (
VERSION = "2024-05-30"
)
var HOST = requests.Host{
Default: "oss.gaore.com",
}
type Client struct {
sdk.Client
}
func NewClient() (client *Client, err error) {
client = new(Client)
err = client.Init()
return
}
func NewClientWithSts() {
}
2024-05-30 18:40:57 +08:00
func (c *Client) PutOss(req *PutOssRequest) (resp *PutOssResponse, err error) {
if req.BucketName == "" {
err = errors.New("bucket name is empty")
return
}
if req.FileStream == nil {
err = errors.New("stream is empty")
return
}
req.SetContent(req.FileStream)
resp = CreatePutOssResponse()
err = c.DoAction(req, resp)
return
}
func (c *Client) DelOss(req *DelOssRequest) (resp *DelOssResponse, err error) {
resp = CreateDelOssResponse()
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
}