From 279cb4feb0a17b1125245cf459ea60c91ce2b7ea Mon Sep 17 00:00:00 2001 From: keroming Date: Thu, 7 May 2020 17:12:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Object.Delete=20=E5=A2=9E=E5=8A=A0=20op?= =?UTF-8?q?tHeader=20=E4=BC=A0=E9=80=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/object/delete.go | 2 +- object.go | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/example/object/delete.go b/example/object/delete.go index 55d4902..ed227c9 100644 --- a/example/object/delete.go +++ b/example/object/delete.go @@ -29,7 +29,7 @@ func main() { name := "test/objectPut.go" - _, err := c.Object.Delete(context.Background(), name) + _, err := c.Object.Delete(context.Background(), name, nil) if err != nil { panic(err) } diff --git a/object.go b/object.go index fd8285b..dd9c358 100644 --- a/object.go +++ b/object.go @@ -272,10 +272,18 @@ func (s *ObjectService) Copy(ctx context.Context, name, sourceURL string, opt *O return &res, resp, err } +type ObjectDeleteOptions struct { + // SSE-C + XCosSSECustomerAglo string `header:"x-cos-server-side-encryption-customer-algorithm,omitempty" url:"-" xml:"-"` + XCosSSECustomerKey string `header:"x-cos-server-side-encryption-customer-key,omitempty" url:"-" xml:"-"` + XCosSSECustomerKeyMD5 string `header:"x-cos-server-side-encryption-customer-key-MD5,omitempty" url:"-" xml:"-"` + //兼容其他自定义头部 + XOptionHeader *http.Header `header:"-,omitempty" url:"-" xml:"-"` +} // Delete Object请求可以将一个文件(Object)删除。 // // https://www.qcloud.com/document/product/436/7743 -func (s *ObjectService) Delete(ctx context.Context, name string) (*Response, error) { +func (s *ObjectService) Delete(ctx context.Context, name string, opt *ObjectDeleteOptions) (*Response, error) { // When use "" string might call the delete bucket interface if len(name) == 0 { return nil, errors.New("empty object name") @@ -285,6 +293,7 @@ func (s *ObjectService) Delete(ctx context.Context, name string) (*Response, err baseURL: s.client.BaseURL.BucketURL, uri: "/" + encodeURIComponent(name), method: http.MethodDelete, + optHeader: opt, } resp, err := s.client.send(ctx, &sendOpt) return resp, err