Skip to content
Objects

Objects

Note

You should have created a client and context in Getting Started

Put an Object

Overwrites the given object. This is a utility wrapper around the lower level Objects.Put and direct http request to the volume server.

err := client.PutObject(ctx, "your_bucket_name", "object_key", []byte("testing content"))
// You can, and should specify a content type
err := client.PutObject(ctx, "your_bucket_name", "object_key", []byte("testing content"), warehouse.WithContentType("text/plain"))

Get an Object

Gets the data of a given object and its bytes. This is a utility wrapper around the lower level Objects.Get and direct http request to the volume server.

data, metadata, err := client.GetObject(ctx, "your_bucket_name", "object_key")

Metadata:

{
  CreatedAt: time.Time,
  Size: int64,
  ContentType: string
}

Delete Object

_, err := client.Objects.Delete(ctx, &proto.ObjectsDeleteRequest{
	Bucket: "your_bucket_name",
	Name:   "object_key",
})

List Objects

objects, err := client.Objects.List(ctx, &proto.ObjectsListRequest{
  Bucket: "your_bucket_name",
  Limit: 10, // Defaults to 10, you can omit
  Offset: 0, // Optional, for pagination
})

Example Response:

{
  "objects": [
    {
      "createdAt": "1776120090",
      "name": "object_key",
      "size": 12
    },
  ]
}

Count Objects

Counts the total number of objects.

count, err := clients.Objects(ctx, nil)

Example Response:

{
  "count": 11
}