Patch Bucket
client.R2.Buckets.Edit(ctx, bucketName, params) (*Bucket, error)
PATCH/accounts/{account_id}/r2/buckets/{bucket_name}
Changes the default storage class for newly uploaded objects in an existing R2 bucket. Existing objects retain their storage class, and individual uploads can override the bucket default.
Security
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
Example:
Patch Bucket
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/r2"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
bucket, err := client.R2.Buckets.Edit(
context.TODO(),
"example-bucket",
r2.BucketEditParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
StorageClass: cloudflare.F(r2.BucketEditParamsCfR2StorageClassStandard),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", bucket.CreationDate)
}
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
"string"
],
"result": {
"creation_date": "creation_date",
"jurisdiction": "default",
"location": "apac",
"name": "example-bucket",
"storage_class": "Standard"
},
"success": true
}Returns Examples
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
"string"
],
"result": {
"creation_date": "creation_date",
"jurisdiction": "default",
"location": "apac",
"name": "example-bucket",
"storage_class": "Standard"
},
"success": true
}