Skip to content

Commit 26ba46d

Browse files
author
jojoliang
committed
update copy
1 parent 563f286 commit 26ba46d

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

example/object/copyPart.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func initUpload(c *cos.Client, name string) *cos.InitiateMultipartUploadResult {
4040
}
4141

4242
func main() {
43-
u, _ := url.Parse("https://test-1253846586.cos.ap-guangzhou.myqcloud.com")
43+
u, _ := url.Parse("https://test-1259654469.cos.ap-guangzhou.myqcloud.com")
4444
b := &cos.BaseURL{BucketURL: u}
4545
c := cos.NewClient(b, &http.Client{
4646
Transport: &cos.AuthorizationTransport{

object.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,9 @@ func (s *ObjectService) Copy(ctx context.Context, name, sourceURL string, opt *O
416416
}
417417
resp, err := s.client.doRetry(ctx, &sendOpt)
418418
// 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.
419-
if err == nil && resp.StatusCode == 200 {
420-
if res.ETag == "" {
421-
return &res, resp, errors.New("response 200 OK, but body contains an error")
419+
if resp != nil && resp.StatusCode == 200 {
420+
if err != nil {
421+
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)
422422
}
423423
}
424424
return &res, resp, err

object_part.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,9 @@ func (s *ObjectService) CopyPart(ctx context.Context, name, uploadID string, par
280280
}
281281
resp, err := s.client.send(ctx, &sendOpt)
282282
// 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.
283-
if err == nil && resp != nil && resp.StatusCode == 200 {
284-
if res.ETag == "" {
285-
return &res, resp, errors.New("response 200 OK, but body contains an error")
283+
if resp != nil && resp.StatusCode == 200 {
284+
if err != nil {
285+
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)
286286
}
287287
}
288288
return &res, resp, err

0 commit comments

Comments
 (0)