Saves a new bucket lifecycle.
(ctx context.Context, bucketName string, buf []byte)
| 53 | |
| 54 | // Saves a new bucket lifecycle. |
| 55 | func (c *Client) putBucketLifecycle(ctx context.Context, bucketName string, buf []byte) error { |
| 56 | // Get resources properly escaped and lined up before |
| 57 | // using them in http request. |
| 58 | urlValues := make(url.Values) |
| 59 | urlValues.Set("lifecycle", "") |
| 60 | |
| 61 | // Content-length is mandatory for put lifecycle request |
| 62 | reqMetadata := requestMetadata{ |
| 63 | bucketName: bucketName, |
| 64 | queryValues: urlValues, |
| 65 | contentBody: bytes.NewReader(buf), |
| 66 | contentLength: int64(len(buf)), |
| 67 | contentMD5Base64: sumMD5Base64(buf), |
| 68 | } |
| 69 | |
| 70 | // Execute PUT to upload a new bucket lifecycle. |
| 71 | resp, err := c.executeMethod(ctx, http.MethodPut, reqMetadata) |
| 72 | defer closeResponse(resp) |
| 73 | if err != nil { |
| 74 | return err |
| 75 | } |
| 76 | if resp != nil { |
| 77 | if resp.StatusCode != http.StatusOK { |
| 78 | return httpRespToErrorResponse(resp, bucketName, "") |
| 79 | } |
| 80 | } |
| 81 | return nil |
| 82 | } |
| 83 | |
| 84 | // Remove lifecycle from a bucket. |
| 85 | func (c *Client) removeBucketLifecycle(ctx context.Context, bucketName string) error { |
no test coverage detected