DeleteObject deletes a single object by its key. https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObject.html
(ctx context.Context, key string, optFuncs ...func(*http.Request))
| 9 | // |
| 10 | // https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObject.html |
| 11 | func (s3 *S3) DeleteObject(ctx context.Context, key string, optFuncs ...func(*http.Request)) error { |
| 12 | req, err := http.NewRequestWithContext(ctx, http.MethodDelete, s3.URL(key), nil) |
| 13 | if err != nil { |
| 14 | return err |
| 15 | } |
| 16 | |
| 17 | // apply optional request funcs |
| 18 | for _, fn := range optFuncs { |
| 19 | if fn != nil { |
| 20 | fn(req) |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | resp, err := s3.SignAndSend(req) |
| 25 | if err != nil { |
| 26 | return err |
| 27 | } |
| 28 | defer resp.Body.Close() |
| 29 | |
| 30 | return nil |
| 31 | } |