diff --git a/go.mod b/go.mod index bac9587705b5e..9f89284834934 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/alicebob/miniredis/v2 v2.33.0 github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible github.com/aws/aws-sdk-go v1.55.5 - github.com/baidubce/bce-sdk-go v0.9.205 + github.com/baidubce/bce-sdk-go v0.9.206 github.com/bmatcuk/doublestar/v4 v4.7.1 github.com/c2h5oh/datasize v0.0.0-20231215233829-aa82cc1e6500 github.com/cespare/xxhash/v2 v2.3.0 diff --git a/go.sum b/go.sum index f366e1c40596b..59c8f36a6b101 100644 --- a/go.sum +++ b/go.sum @@ -1008,8 +1008,8 @@ github.com/aws/smithy-go v1.11.1 h1:IQ+lPZVkSM3FRtyaDox41R8YS6iwPMYIreejOgPW49g= github.com/aws/smithy-go v1.11.1/go.mod h1:3xHYmszWVx2c0kIwQeEVf9uSm4fYZt67FBJnwub1bgM= github.com/axiomhq/hyperloglog v0.2.1 h1:z+rouIlYdpZ+DVfnQigBimhQL6OKHIL3e8+hMiud5/c= github.com/axiomhq/hyperloglog v0.2.1/go.mod h1:WCdOZ8PNJKNcBw3xFZ7iHlnUn1nDVHK/XToLjjmySh4= -github.com/baidubce/bce-sdk-go v0.9.205 h1:9cx93gC4FSu3W3G4NkDfFl0XMUycCpvQN+nB3doNmvg= -github.com/baidubce/bce-sdk-go v0.9.205/go.mod h1:zbYJMQwE4IZuyrJiFO8tO8NbtYiKTFTbwh4eIsqjVdg= +github.com/baidubce/bce-sdk-go v0.9.206 h1:1nmKLHWCkPzpmVATiC15+4q/lYkx4PdXd2qKfYUzTes= +github.com/baidubce/bce-sdk-go v0.9.206/go.mod h1:zbYJMQwE4IZuyrJiFO8tO8NbtYiKTFTbwh4eIsqjVdg= github.com/bboreham/go-loser v0.0.0-20230920113527-fcc2c21820a3 h1:6df1vn4bBlDDo4tARvBm7l6KA9iVMnE3NWizDeWSrps= github.com/bboreham/go-loser v0.0.0-20230920113527-fcc2c21820a3/go.mod h1:CIWtjkly68+yqLPbvwwR/fjNJA/idrtULjZWh2v1ys0= github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= diff --git a/vendor/github.com/baidubce/bce-sdk-go/bce/config.go b/vendor/github.com/baidubce/bce-sdk-go/bce/config.go index dde687a70cc0d..90cbb873f3992 100644 --- a/vendor/github.com/baidubce/bce-sdk-go/bce/config.go +++ b/vendor/github.com/baidubce/bce-sdk-go/bce/config.go @@ -26,7 +26,7 @@ import ( // Constants and default values for the package bce const ( - SDK_VERSION = "0.9.205" + SDK_VERSION = "0.9.206" URI_PREFIX = "/" // now support uri without prefix "v1" so just set root path DEFAULT_DOMAIN = "baidubce.com" DEFAULT_PROTOCOL = "http" diff --git a/vendor/github.com/baidubce/bce-sdk-go/services/bos/api/bucket.go b/vendor/github.com/baidubce/bce-sdk-go/services/bos/api/bucket.go index 3e05fcd0a05ea..c6aa312ab4f60 100644 --- a/vendor/github.com/baidubce/bce-sdk-go/services/bos/api/bucket.go +++ b/vendor/github.com/baidubce/bce-sdk-go/services/bos/api/bucket.go @@ -19,6 +19,7 @@ package api import ( "encoding/json" + "fmt" "strconv" "github.com/baidubce/bce-sdk-go/bce" @@ -1253,3 +1254,48 @@ func DeleteBucketTag(cli bce.Client, bucket string, ctx *BosContext) error { defer func() { resp.Body().Close() }() return nil } + +func GetBosShareLink(cli bce.Client, bucket, prefix, shareCode string, duration int) (string, error) { + req := &bce.BceRequest{} + req.SetEndpoint(BOS_SHARE_ENDPOINT) + req.SetParam("action", "") + req.SetMethod(http.POST) + if len(shareCode) != 0 && len(shareCode) != 6 { + return "", fmt.Errorf("shareCode length must be 0 or 6") + } + if duration < 60 || duration > 64800 { + return "", fmt.Errorf("duration must between 1 minute and 18 hours") + } + bosShareReqBody := &BosShareLinkArgs{ + Bucket: bucket, + Endpoint: cli.GetBceClientConfig().Endpoint, + Prefix: prefix, + ShareCode: shareCode, + DurationSeconds: int64(duration), + } + jsonBytes, jsonErr := json.Marshal(bosShareReqBody) + if jsonErr != nil { + return "", jsonErr + } + body, err := bce.NewBodyFromBytes(jsonBytes) + if err != nil { + return "", err + } + req.SetBody(body) + resp := &bce.BceResponse{} + if err = cli.SendRequest(req, resp); err != nil { + return "", err + } + if resp.IsFail() { + return "", resp.ServiceError() + } + bosShareResBody := &BosShareResBody{} + if err := resp.ParseJsonBody(bosShareResBody); err != nil { + return "", err + } + jsonData, err := json.Marshal(bosShareResBody) + if err != nil { + return "", err + } + return string(jsonData), nil +} diff --git a/vendor/github.com/baidubce/bce-sdk-go/services/bos/api/model.go b/vendor/github.com/baidubce/bce-sdk-go/services/bos/api/model.go index 7d4007e030ecc..c59ee8f6bf06d 100644 --- a/vendor/github.com/baidubce/bce-sdk-go/services/bos/api/model.go +++ b/vendor/github.com/baidubce/bce-sdk-go/services/bos/api/model.go @@ -670,3 +670,17 @@ type ObjectTag struct { Key string `json:"key"` Value string `json:"value"` } + +type BosShareLinkArgs struct { + Bucket string `json:"bucket"` + Endpoint string `json:"endpoint"` + Prefix string `json:"prefix"` + ShareCode string `json:"shareCode"` + DurationSeconds int64 `json:"durationSeconds"` +} + +type BosShareResBody struct { + ShareUrl string `json:"shareUrl"` + LinkExpireTime int64 `json:"linkExpireTime"` + ShareCode string `json:"shareCode"` +} \ No newline at end of file diff --git a/vendor/github.com/baidubce/bce-sdk-go/services/bos/api/util.go b/vendor/github.com/baidubce/bce-sdk-go/services/bos/api/util.go index b2fa1e2e88394..e4226c37b925c 100644 --- a/vendor/github.com/baidubce/bce-sdk-go/services/bos/api/util.go +++ b/vendor/github.com/baidubce/bce-sdk-go/services/bos/api/util.go @@ -66,6 +66,7 @@ const ( NAMESPACE_BUCKET = "namespace" BOS_CONFIG_PREFIX = "bos://" + BOS_SHARE_ENDPOINT = "bos-share.baidubce.com" ) var DEFAULT_CNAME_LIKE_LIST = []string{ diff --git a/vendor/github.com/baidubce/bce-sdk-go/services/bos/client.go b/vendor/github.com/baidubce/bce-sdk-go/services/bos/client.go index a3bd985e7a1e1..9230a0231424a 100644 --- a/vendor/github.com/baidubce/bce-sdk-go/services/bos/client.go +++ b/vendor/github.com/baidubce/bce-sdk-go/services/bos/client.go @@ -2310,3 +2310,7 @@ func (c *Client) GetObjectTag(bucket string, object string) (map[string]interfac func (c *Client) DeleteObjectTag(bucket string, object string) error { return api.DeleteObjectTag(c, bucket, object, c.BosContext) } + +func (c *Client) BosShareLinkGet(bucket string, prefix string, shareCode string, duration int) (string, error) { + return api.GetBosShareLink(c, bucket, prefix, shareCode, duration) +} \ No newline at end of file diff --git a/vendor/modules.txt b/vendor/modules.txt index 7810d1ce504bf..0ae3d624eb6ef 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -465,7 +465,7 @@ github.com/aws/smithy-go/transport/http/internal/io # github.com/axiomhq/hyperloglog v0.2.1 ## explicit; go 1.23 github.com/axiomhq/hyperloglog -# github.com/baidubce/bce-sdk-go v0.9.205 +# github.com/baidubce/bce-sdk-go v0.9.206 ## explicit; go 1.11 github.com/baidubce/bce-sdk-go/auth github.com/baidubce/bce-sdk-go/bce