first commit
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package cos
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"git.lzcwy.cn/zhengchiliu/zt-closet-backend/global"
|
||||
"github.com/tencentyun/cos-go-sdk-v5"
|
||||
)
|
||||
|
||||
func NewCosClient() (*cos.Client, error) {
|
||||
u, err := url.Parse("https://" + global.CosSetting.CosUploadDomain)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parse cos upload domain: %w", err)
|
||||
}
|
||||
b := &cos.BaseURL{BucketURL: u}
|
||||
client := cos.NewClient(b, &http.Client{
|
||||
Transport: &cos.AuthorizationTransport{
|
||||
SecretID: global.CosSetting.CosSecretID,
|
||||
SecretKey: global.CosSetting.CosSecretKey,
|
||||
},
|
||||
})
|
||||
|
||||
return client, nil
|
||||
}
|
||||
Reference in New Issue
Block a user