Skip to content

Commit

Permalink
feat: 改为可选参数,向下兼容
Browse files Browse the repository at this point in the history
  • Loading branch information
keroming committed May 7, 2020
1 parent 279cb4f commit 2eee514
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions object.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,17 +283,21 @@ type ObjectDeleteOptions struct {
// Delete Object请求可以将一个文件(Object)删除。
//
// https://www.qcloud.com/document/product/436/7743
func (s *ObjectService) Delete(ctx context.Context, name string, opt *ObjectDeleteOptions) (*Response, error) {
func (s *ObjectService) Delete(ctx context.Context, name string, opt ...*ObjectDeleteOptions) (*Response, error) {
var optHeader *ObjectDeleteOptions
// When use "" string might call the delete bucket interface
if len(name) == 0 {
return nil, errors.New("empty object name")
}
if len(opt) > 0 {
optHeader = opt[0]
}

sendOpt := sendOptions{
baseURL: s.client.BaseURL.BucketURL,
uri: "/" + encodeURIComponent(name),
method: http.MethodDelete,
optHeader: opt,
optHeader: optHeader,
}
resp, err := s.client.send(ctx, &sendOpt)
return resp, err
Expand Down

0 comments on commit 2eee514

Please sign in to comment.