---
title: "Blobstore Operations (NATS) | Cosmonic"
description: "Demonstration of blob storage operations via HTTP, implemented as a Wasm component for Cosmonic Control."
canonical: "https://cosmonic.com/docs/template-catalog/blobstore-nats/"
---

# Blobstore Operations (NATS)

A demonstration of blob storage operations that exposes the results via HTTP, implemented as a Wasm component and packaged for Cosmonic Control.

## Deploy with Helm

```shell
helm install blobstore-nats --version 0.2.0 oci://ghcr.io/cosmonic-labs/charts/http-trigger -f https://raw.githubusercontent.com/cosmonic-labs/control-demos/refs/heads/main/blobstore-nats/values.http-trigger.yaml
```

**Repository**: [`cosmonic-labs/control-demos/blobstore-nats`](https://github.com/cosmonic-labs/control-demos/tree/main/blobstore-nats)  
**Languages**: Rust  
**Interfaces**: `wasi/http`, `wasi/blobstore`

## Running on Kubernetes

You will need a local Kubernetes environment with Cosmonic Control installed according to the [Get Started](https://cosmonic.com/docs/install-cosmonic-control/) guide.

Connect to the component at `http://blobstore.localhost.cosmonic.sh`:

```shell
curl http://blobstore.localhost.cosmonic.sh
```

The component will return a JSON response showing the results of all operations:

```json
{
  "container_ops": {
    "create_container": {
      "success": true,
      "message": "Created ying",
      "timestamp": "2024-12-05 16:30:00 UTC"
    },
    "container_info": {
      "success": true,
      "message": "Container ying created at 2024-12-05 16:30:00 UTC",
      "timestamp": "2024-12-05 16:30:00 UTC"
    }
    // ... more container operations
  },
  "blob_ops": {
    "write_blob": {
      "success": true,
      "message": "Wrote earth to ying",
      "timestamp": "2024-12-05 16:30:01 UTC"
    }
    // ... more blob operations
  },
  "container_names": ["ying", "yang"]
}
```

The component performs a series of blobstore operations:

1. Container Operations:
   - Creates two containers (default: "ying" and "yang")
   - Verifies container existence
   - Retrieves container metadata
2. Basic Blob Operations:
   - Writes four blobs ("earth", "air", "fire", "water") to "ying" container
   - Reads back and verifies content
   - Demonstrates partial content reading (first 4 bytes)
3. Advanced Operations:
   - Moves "fire" from "ying" to "yang" container
   - Copies "water" from "ying" to "yang" container
   - Lists objects in both containers
   - Cleans up by clearing "ying" container

## Development

Development requirements:

- [`cargo`](https://www.rust-lang.org/tools/install) 1.82+ for the Rust toolchain
- `wasm32-wasip2` target for Rust: Install with `rustup target add wasm32-wasip2`
- [Wasm Shell (`wash`)](https://github.com/wasmCloud/wasmcloud) **v2.0.4** for component development

Clone the [`cosmonic-labs/control-demos`](https://github.com/cosmonic-labs/control-demos) repository:

```shell
git clone https://github.com/cosmonic-labs/control-demos.git
```

```shell
cd control-demos/blobstore-nats
```

Start the development loop:

```shell
wash dev
```

The component is accessible at localhost:8000. View the code and make changes in `src/lib.rs`.

You can cancel the `wash dev` process with `Ctrl-C`.

### Build the Wasm Binary

Compile the component:

```shell
wash build
```

The `.wasm` binary will output to `/target/wasm32-wasip2/debug`.

## Learn More

- See the wasmCloud Developer Guide for instructions on [pushing your Wasm component to an OCI registry](https://wasmcloud.com/docs/wash/developer-guide/).

- To learn how to extend this example with additional capabilities, see the [Adding Capabilities](https://wasmcloud.com/docs/tour/adding-capabilities?lang=rust) section of the wasmCloud documentation.
- For more on building components in Go, see the [Component Developer Guide](https://wasmcloud.com/docs/developer/languages/go/components/) in the wasmCloud documentation.

Last updated on **Nov 10, 2026** by **Liam Randall**
