From a87afe3e5cb41d37b273adac0d081c9588a82163 Mon Sep 17 00:00:00 2001 From: toranger Date: Mon, 1 Jul 2019 11:14:57 +0800 Subject: [PATCH] Fix the options param to listparts interface --- example/object/listParts.go | 7 +++++-- object_part.go | 11 ++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/example/object/listParts.go b/example/object/listParts.go index a0b7a1c..20ec7aa 100644 --- a/example/object/listParts.go +++ b/example/object/listParts.go @@ -43,7 +43,7 @@ func uploadPart(c *cos.Client, name string, uploadID string, blockSize, n int) s } func main() { - u, _ := url.Parse("https://test-1253846586.cos.ap-guangzhou.myqcloud.com") + u, _ := url.Parse("http://alangz-1251668577.cos.ap-guangzhou.myqcloud.com") b := &cos.BaseURL{BucketURL: u} c := cos.NewClient(b, &http.Client{ Transport: &cos.AuthorizationTransport{ @@ -68,7 +68,10 @@ func main() { uploadPart(c, name, uploadID, blockSize, i) } - v, _, err := c.Object.ListParts(ctx, name, uploadID) + // opt := &cos.ObjectListPartsOptions{ + // MaxParts: 1, + // } + v, _, err := c.Object.ListParts(ctx, name, uploadID, nil) if err != nil { panic(err) return diff --git a/object_part.go b/object_part.go index 196fa7a..dc7185e 100644 --- a/object_part.go +++ b/object_part.go @@ -94,14 +94,15 @@ type ObjectListPartsResult struct { // ListParts 用来查询特定分块上传中的已上传的块。 // // https://www.qcloud.com/document/product/436/7747 -func (s *ObjectService) ListParts(ctx context.Context, name, uploadID string) (*ObjectListPartsResult, *Response, error) { +func (s *ObjectService) ListParts(ctx context.Context, name, uploadID string, opt *ObjectListPartsOptions) (*ObjectListPartsResult, *Response, error) { u := fmt.Sprintf("/%s?uploadId=%s", encodeURIComponent(name), uploadID) var res ObjectListPartsResult sendOpt := sendOptions{ - baseURL: s.client.BaseURL.BucketURL, - uri: u, - method: http.MethodGet, - result: &res, + baseURL: s.client.BaseURL.BucketURL, + uri: u, + method: http.MethodGet, + result: &res, + optQuery: opt, } resp, err := s.client.send(ctx, &sendOpt) return &res, resp, err