RemoveBucket deletes the bucket name. All objects (including all object versions and delete markers). in the bucket must be deleted before successfully attempting this request.
(ctx context.Context, bucketName string)
| 94 | // All objects (including all object versions and delete markers). |
| 95 | // in the bucket must be deleted before successfully attempting this request. |
| 96 | func (c *Client) RemoveBucket(ctx context.Context, bucketName string) error { |
| 97 | // Input validation. |
| 98 | if err := s3utils.CheckValidBucketName(bucketName); err != nil { |
| 99 | return err |
| 100 | } |
| 101 | // Execute DELETE on bucket. |
| 102 | resp, err := c.executeMethod(ctx, http.MethodDelete, requestMetadata{ |
| 103 | bucketName: bucketName, |
| 104 | contentSHA256Hex: emptySHA256Hex, |
| 105 | }) |
| 106 | defer closeResponse(resp) |
| 107 | if err != nil { |
| 108 | return err |
| 109 | } |
| 110 | if resp != nil { |
| 111 | if resp.StatusCode != http.StatusNoContent { |
| 112 | return httpRespToErrorResponse(resp, bucketName, "") |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | // Remove the location from cache on a successful delete. |
| 117 | c.bucketLocCache.Delete(bucketName) |
| 118 | |
| 119 | return nil |
| 120 | } |
| 121 | |
| 122 | // AdvancedRemoveOptions intended for internal use by replication |
| 123 | type AdvancedRemoveOptions struct { |