Skip to content
Buckets

Buckets

Note

You should have created a client and context in Getting Started

Create a Bucket

_, err := client.Buckets.Create(ctx, &proto.BucketsCreateRequest{
  Name: "your_bucket_name",
})
Common Errors
Bucket name must be between 1 and 32 characters
Bucket name can only contain the characters a-z, 0-9, ‘_’, or ‘.’
Bucket with that name already exists

List Buckets

Gets a list of buckets including object count and total size of buckets

With Defaults:

// Default limit = 10, offset = 0
buckets, err := client.Buckets.List(ctx, nil)

Custom Limit/Offset (for pagination):

buckets, err := client.Buckets.List(ctx, &proto.BucketsListRequest{
  Limit: 100, 
  Offset: 0,
})

Example Response:

{
  "buckets": [
    {
      "name": "your_bucket_name",
      "objects": 12,
      "totalSize": 7516192888
    }
  ]
}

Retrieve a Bucket

Retrieves bucket information like object count and total size

bucket, err := client.Buckets.Get(ctx, &proto.BucketsGetRequest{
  Name: "your_bucket_name"
})

Example Response:

{
  "name": "your_bucket_name",
  "objects": 12,
  "totalSize": 7516192888
}

Delete a Bucket

Deletes a bucket and references to objects it contains. Does not currently remove each physical object

_, err := client.Buckets.Delete(ctx, &proto.BucketsDeleteRequest{
  Name: "your_bucket_name",
})

Count Buckets

count, err := client.Buckets.Count(ctx, nil)

Example Response:

{
  "count": 1
}