Skip to content

Commit

Permalink
update copy
Browse files Browse the repository at this point in the history
  • Loading branch information
jojoliang committed Aug 25, 2022
1 parent 563f286 commit 26ba46d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion example/object/copyPart.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func initUpload(c *cos.Client, name string) *cos.InitiateMultipartUploadResult {
}

func main() {
u, _ := url.Parse("https://test-1253846586.cos.ap-guangzhou.myqcloud.com")
u, _ := url.Parse("https://test-1259654469.cos.ap-guangzhou.myqcloud.com")
b := &cos.BaseURL{BucketURL: u}
c := cos.NewClient(b, &http.Client{
Transport: &cos.AuthorizationTransport{
Expand Down
6 changes: 3 additions & 3 deletions object.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,9 @@ func (s *ObjectService) Copy(ctx context.Context, name, sourceURL string, opt *O
}
resp, err := s.client.doRetry(ctx, &sendOpt)
// If the error occurs during the copy operation, the error response is embedded in the 200 OK response. This means that a 200 OK response can contain either a success or an error.
if err == nil && resp.StatusCode == 200 {
if res.ETag == "" {
return &res, resp, errors.New("response 200 OK, but body contains an error")
if resp != nil && resp.StatusCode == 200 {
if err != nil {
return &res, resp, fmt.Errorf("response 200 OK, but body contains an error, RequestId: %v, Error: %v", resp.Header.Get("X-Cos-Request-Id"), err)
}
}
return &res, resp, err
Expand Down
6 changes: 3 additions & 3 deletions object_part.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@ func (s *ObjectService) CopyPart(ctx context.Context, name, uploadID string, par
}
resp, err := s.client.send(ctx, &sendOpt)
// If the error occurs during the copy operation, the error response is embedded in the 200 OK response. This means that a 200 OK response can contain either a success or an error.
if err == nil && resp != nil && resp.StatusCode == 200 {
if res.ETag == "" {
return &res, resp, errors.New("response 200 OK, but body contains an error")
if resp != nil && resp.StatusCode == 200 {
if err != nil {
return &res, resp, fmt.Errorf("response 200 OK, but body contains an error, RequestId: %v, Error: %v", resp.Header.Get("X-Cos-Request-Id"), err)
}
}
return &res, resp, err
Expand Down

0 comments on commit 26ba46d

Please sign in to comment.