Browse Source

feat: Object.Delete 增加 optHeader 传递

tags/v0.7.5
keroming 5 years ago
parent
commit
279cb4feb0
  1. 2
      example/object/delete.go
  2. 11
      object.go

2
example/object/delete.go

@ -29,7 +29,7 @@ func main() {
name := "test/objectPut.go" name := "test/objectPut.go"
_, err := c.Object.Delete(context.Background(), name)
_, err := c.Object.Delete(context.Background(), name, nil)
if err != nil { if err != nil {
panic(err) panic(err)
} }

11
object.go

@ -272,10 +272,18 @@ func (s *ObjectService) Copy(ctx context.Context, name, sourceURL string, opt *O
return &res, resp, err 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)删除。 // Delete Object请求可以将一个文件(Object)删除。
// //
// https://www.qcloud.com/document/product/436/7743 // 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 // When use "" string might call the delete bucket interface
if len(name) == 0 { if len(name) == 0 {
return nil, errors.New("empty object name") 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, baseURL: s.client.BaseURL.BucketURL,
uri: "/" + encodeURIComponent(name), uri: "/" + encodeURIComponent(name),
method: http.MethodDelete, method: http.MethodDelete,
optHeader: opt,
} }
resp, err := s.client.send(ctx, &sendOpt) resp, err := s.client.send(ctx, &sendOpt)
return resp, err return resp, err

Loading…
Cancel
Save