Skip to content

Commit

Permalink
Merge pull request #83 from agin719/common-dev
Browse files Browse the repository at this point in the history
x-cos-copy-source urlencode修正
  • Loading branch information
agin719 authored Aug 31, 2020
2 parents e870e71 + 17c5ed1 commit 31af2de
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cos.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

const (
// Version current go sdk version
Version = "0.7.7"
Version = "0.7.8"
userAgent = "cos-go-sdk-v5/" + Version
contentTypeXML = "application/xml"
defaultServiceBaseURL = "http://service.cos.myqcloud.com"
Expand Down
9 changes: 7 additions & 2 deletions object.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"net/url"
"os"
"sort"
"strings"
"time"
)

Expand Down Expand Up @@ -236,11 +237,15 @@ type ObjectCopyResult struct {
//
// https://cloud.tencent.com/document/product/436/10881
func (s *ObjectService) Copy(ctx context.Context, name, sourceURL string, opt *ObjectCopyOptions, id ...string) (*ObjectCopyResult, *Response, error) {
surl := strings.SplitN(sourceURL, "/", 2)
if len(surl) < 2 {
return nil, nil, errors.New(fmt.Sprintf("x-cos-copy-source format error: %s", sourceURL))
}
var u string
if len(id) == 1 {
u = fmt.Sprintf("%s?versionId=%s", encodeURIComponent(sourceURL), id[0])
u = fmt.Sprintf("%s/%s?versionId=%s", surl[0], encodeURIComponent(surl[1]), id[0])
} else if len(id) == 0 {
u = encodeURIComponent(sourceURL)
u = fmt.Sprintf("%s/%s", surl[0], encodeURIComponent(surl[1]))
} else {
return nil, nil, errors.New("wrong params")
}
Expand Down

0 comments on commit 31af2de

Please sign in to comment.