---
title: Volumes
description: TypeScript SDK - Volume API reference
---

Create, manage, and mount named volumes. See [Volumes](/sandboxes/volumes) for usage examples.

## Volume

<p className="msb-member-group">Instance properties</p>

#### <span className="msb-recv">volume.</span><span className="msb-hn">name</span>

```typescript
get name(): string
```

The volume's name.

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Volume name.</div>
  </div>
</div>

#### <span className="msb-recv">volume.</span><span className="msb-hn">path</span>

```typescript
get path(): string
```

Absolute host path to the volume's directory. By default volumes live under `~/.microsandbox/volumes/<name>/`.

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Absolute host directory path.</div>
  </div>
</div>

<p className="msb-member-group">Static methods</p>

#### <span className="msb-recv">Volume.</span><span className="msb-hn">getDefault()</span>

```typescript
static getDefault(): Promise<VolumeHandle>
```

Get the Cloud account's always-present default volume. It has no user-assigned name, cannot be removed, and supports direct filesystem operations through `.fs()`. The local backend returns a typed `Unsupported` error; it never substitutes a directory from the caller's machine.

```typescript
const volume = await Volume.getDefault();
await volume.fs().write("customers/acme.json", JSON.stringify({ active: true }));
console.log(await volume.fs().readToString("customers/acme.json"));
```

#### <span className="msb-recv">Volume.</span><span className="msb-hn">builder()</span>

```typescript
static builder(name: string): VolumeBuilder
```

<Accordion title="Example">

```typescript
const data = await Volume.builder("my-data")
  .label("env", "prod")
  .create();
```

</Accordion>

Begin building a named volume. Directory-backed volumes are the default. Call `.disk().size(...)` for a disk-backed volume. See [`VolumeBuilder`](#volumebuilder) for all options.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>name</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Volume name.</div>
  </div>
</div>

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><a className="msb-type" href="#volume-builder">VolumeBuilder</a></div>
    <div className="msb-param-desc">Fluent builder for configuring the volume.</div>
  </div>
</div>

#### <span className="msb-recv">Volume.</span><span className="msb-hn">get()</span>

```typescript
static get(name: string): Promise<VolumeHandle>
```

<Accordion title="Example">

```typescript
const handle = await Volume.get("my-data");
console.log(handle.usedBytes);
```

</Accordion>

Get a live handle to an existing named volume. A live handle supports `.fs()` and `.remove()`, unlike the read-only handles returned by [`list()`](#volume-list).

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>name</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Volume name.</div>
  </div>
</div>

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><a className="msb-type" href="#volumehandle">Promise&lt;VolumeHandle&gt;</a></div>
    <div className="msb-param-desc">Live handle with metadata, filesystem access, and removal.</div>
  </div>
</div>

#### <span className="msb-recv">Volume.</span><span className="msb-hn">list()</span>

```typescript
static list(): Promise<VolumeHandle[]>
```

<Accordion title="Example">

```typescript
for (const v of await Volume.list()) {
  console.log(`${v.name} - ${v.kind} - ${v.usedBytes} bytes`);
}
```

</Accordion>

List all named volumes. Handles returned here are **read-only**: calling `.fs()` or `.remove()` on them throws. Call [`Volume.get(name)`](#volume-get) to upgrade to a live handle.

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><a className="msb-type" href="#volumehandle">Promise&lt;VolumeHandle[]&gt;</a></div>
    <div className="msb-param-desc">All volumes, as read-only handles.</div>
  </div>
</div>

#### <span className="msb-recv">Volume.</span><span className="msb-hn">remove()</span>

```typescript
static remove(name: string): Promise<void>
```

<Accordion title="Example">

```typescript
await Volume.remove("my-data");
```

</Accordion>

Delete a named volume and its contents. Fails if the volume is currently mounted by a sandbox.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>name</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Volume name.</div>
  </div>
</div>

<p className="msb-member-group">Instance methods</p>

#### <span className="msb-recv">volume.</span><span className="msb-hn">fs()</span>

<Tooltip tip="Unmounted-volume filesystem access is not available on microsandbox cloud; mount the volume into a sandbox and use the sandbox filesystem."><span className="msb-badge-local">Local-only <Icon icon="circle-info" size={11} /></span></Tooltip>

```typescript
fs(): VolumeFs
```

<Accordion title="Example">

```typescript
const vfs = data.fs();
await vfs.write("seed.txt", "hello");
console.log(await vfs.readToString("seed.txt"));
```

</Accordion>

Get a filesystem handle for this volume. Local reads and writes use the managed host directory; Cloud reads and writes use the authenticated volume API. No sandbox needs to be running. See [`VolumeFs`](#volumefs-methods) for the full API.

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><a className="msb-type" href="#volumefs">VolumeFs</a></div>
    <div className="msb-param-desc">Host-side filesystem handle.</div>
  </div>
</div>

## VolumeBuilder

Fluent builder for a named volume. Obtained via [`Volume.builder(name)`](#volume-builder). Directory-backed volumes are the default; call [`disk()`](#disk) plus [`size()`](#size) for a disk-backed volume. Every setter returns the builder, so calls chain.

#### <span className="msb-recv">volumeBuilder.</span><span className="msb-hn">directory()</span>

```typescript
directory(): this
```

Create a directory-backed volume. This is the default, so calling it is only needed for clarity.

#### <span className="msb-recv">volumeBuilder.</span><span className="msb-hn">disk()</span>

<Tooltip tip="Disk-kind volumes are not available on microsandbox cloud; use a directory-backed named volume."><span className="msb-badge-local">Local-only <Icon icon="circle-info" size={11} /></span></Tooltip>

```typescript
disk(): this
```

<Accordion title="Example">

```typescript
const dockerData = await Volume.builder("docker-data")
  .disk()
  .size(20 * 1024)
  .create();
```

</Accordion>

Create a raw ext4 disk-backed volume. Pair with [`size()`](#size) to set the capacity.

#### <span className="msb-recv">volumeBuilder.</span><span className="msb-hn">size()</span>

<Tooltip tip="Disk-kind volumes are not available on microsandbox cloud; use a directory-backed named volume."><span className="msb-badge-local">Local-only <Icon icon="circle-info" size={11} /></span></Tooltip>

```typescript
size(mib: number): this
```

Set the disk capacity in MiB. Required after [`disk()`](#disk).

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>mib</code><span className="msb-type">number</span></div>
    <div className="msb-param-desc">Disk capacity in MiB.</div>
  </div>
</div>

#### <span className="msb-recv">volumeBuilder.</span><span className="msb-hn">quota()</span>

<Tooltip tip="On microsandbox cloud, quota sets a storage cap and must be a whole number of GiB."><span className="msb-badge-note">On cloud <Icon icon="circle-info" size={11} /></span></Tooltip>

```typescript
quota(mib: number): this
```

Record a quota in MiB as metadata for directory-backed volumes.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>mib</code><span className="msb-type">number</span></div>
    <div className="msb-param-desc">Quota in MiB.</div>
  </div>
</div>

#### <span className="msb-recv">volumeBuilder.</span><span className="msb-hn">label()</span>

```typescript
label(key: string, value: string): this
```

Add a metadata label. Can be called multiple times.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>key</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Label key.</div>
  </div>
  <div className="msb-param">
    <div className="msb-param-key"><code>value</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Label value.</div>
  </div>
</div>

#### <span className="msb-recv">volumeBuilder.</span><span className="msb-hn">build()</span>

```typescript
build(): { name: string; kind: string; quotaMib?: number | null; capacityMib?: number | null; labels: Record<string, string> }
```

Materialize the volume configuration without creating the volume on disk. To create it, use [`create()`](#create) instead. The returned config object is the internal `NapiVolumeConfig` shape (not a public export).

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><span className="msb-type">{`{ name, kind, quotaMib?, capacityMib?, labels }`}</span></div>
    <div className="msb-param-desc">Frozen volume configuration object.</div>
  </div>
</div>

#### <span className="msb-recv">volumeBuilder.</span><span className="msb-hn">create()</span>

```typescript
create(): Promise<Volume>
```

<Accordion title="Example">

```typescript
const data = await Volume.builder("my-data").create();
```

</Accordion>

Build and create the volume on disk, returning a [`Volume`](#instance-methods).

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><a className="msb-type" href="#instance-methods">Promise&lt;Volume&gt;</a></div>
    <div className="msb-param-desc">The created volume.</div>
  </div>
</div>

## VolumeFs

<p className="msb-backref">Returned by <a href="#volume-fs">volume.fs()</a> · <a href="#volumehandle">VolumeHandle.fs()</a></p>

Host-side filesystem operations for a named volume.

#### <span className="msb-recv">vfs.</span><span className="msb-hn">read()</span>

<Tooltip tip="Unmounted-volume filesystem access is not available on microsandbox cloud; mount the volume into a sandbox and use the sandbox filesystem."><span className="msb-badge-local">Local-only <Icon icon="circle-info" size={11} /></span></Tooltip>

```typescript
read(path: string): Promise<Uint8Array>
```

<Accordion title="Example">

```typescript
const bytes = await vfs.read("data.bin");
```

</Accordion>

Read a file's full contents as bytes.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>path</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Path relative to the volume root.</div>
  </div>
</div>

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><span className="msb-type">Promise&lt;Uint8Array&gt;</span></div>
    <div className="msb-param-desc">File contents.</div>
  </div>
</div>

#### <span className="msb-recv">vfs.</span><span className="msb-hn">readToString()</span>

<Tooltip tip="Unmounted-volume filesystem access is not available on microsandbox cloud; mount the volume into a sandbox and use the sandbox filesystem."><span className="msb-badge-local">Local-only <Icon icon="circle-info" size={11} /></span></Tooltip>

```typescript
readToString(path: string): Promise<string>
```

<Accordion title="Example">

```typescript
const text = await vfs.readToString("config.json");
```

</Accordion>

Read a file's full contents as a UTF-8 string.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>path</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Path relative to the volume root.</div>
  </div>
</div>

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><span className="msb-type">Promise&lt;string&gt;</span></div>
    <div className="msb-param-desc">Decoded file contents.</div>
  </div>
</div>

#### <span className="msb-recv">vfs.</span><span className="msb-hn">readStream()</span>

<Tooltip tip="Unmounted-volume filesystem access is not available on microsandbox cloud; mount the volume into a sandbox and use the sandbox filesystem."><span className="msb-badge-local">Local-only <Icon icon="circle-info" size={11} /></span></Tooltip>

```typescript
readStream(path: string): Promise<VolumeFsReadStream>
```

<Accordion title="Example">

```typescript
const stream = await vfs.readStream("large.bin");
for await (const chunk of stream) {
  console.log(chunk.byteLength);
}
```

</Accordion>

Open a streaming reader for a file, for chunked reads of large files without loading them fully into memory.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>path</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Path relative to the volume root.</div>
  </div>
</div>

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><a className="msb-type" href="#volumefsreadstream">Promise&lt;VolumeFsReadStream&gt;</a></div>
    <div className="msb-param-desc">Async-iterable read stream.</div>
  </div>
</div>

#### <span className="msb-recv">vfs.</span><span className="msb-hn">write()</span>

<Tooltip tip="Unmounted-volume filesystem access is not available on microsandbox cloud; mount the volume into a sandbox and use the sandbox filesystem."><span className="msb-badge-local">Local-only <Icon icon="circle-info" size={11} /></span></Tooltip>

```typescript
write(path: string, data: Uint8Array | string): Promise<void>
```

<Accordion title="Example">

```typescript
await vfs.write("seed.txt", "hello");
```

</Accordion>

Write a file, replacing any existing contents. Strings are encoded as UTF-8.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>path</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Path relative to the volume root.</div>
  </div>
  <div className="msb-param">
    <div className="msb-param-key"><code>data</code><span className="msb-type">Uint8Array | string</span></div>
    <div className="msb-param-desc">Bytes, or a UTF-8 string.</div>
  </div>
</div>

#### <span className="msb-recv">vfs.</span><span className="msb-hn">writeStream()</span>

<Tooltip tip="Unmounted-volume filesystem access is not available on microsandbox cloud; mount the volume into a sandbox and use the sandbox filesystem."><span className="msb-badge-local">Local-only <Icon icon="circle-info" size={11} /></span></Tooltip>

```typescript
writeStream(path: string): Promise<VolumeFsWriteSink>
```

<Accordion title="Example">

```typescript
const sink = await vfs.writeStream("out.bin");
await sink.write(chunk);
await sink.close();
```

</Accordion>

Open a streaming writer for a file, for chunked writes of large files.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>path</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Path relative to the volume root.</div>
  </div>
</div>

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><a className="msb-type" href="#volumefswritesink">Promise&lt;VolumeFsWriteSink&gt;</a></div>
    <div className="msb-param-desc">Write sink; call <code>close()</code> when done.</div>
  </div>
</div>

#### <span className="msb-recv">vfs.</span><span className="msb-hn">list()</span>

```typescript
list(path: string): Promise<FsEntry[]>
```

<Accordion title="Example">

```typescript
for (const e of await vfs.list("")) {
  console.log(e.path, e.kind, e.size);
}
```

</Accordion>

List the entries in a directory. Pass `""` for the volume root.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>path</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Directory path relative to the volume root.</div>
  </div>
</div>

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><a className="msb-type" href="/sdk/typescript/filesystem#fsentry">Promise&lt;FsEntry[]&gt;</a></div>
    <div className="msb-param-desc">Directory entries.</div>
  </div>
</div>

#### <span className="msb-recv">vfs.</span><span className="msb-hn">mkdir()</span>

```typescript
mkdir(path: string): Promise<void>
```

<Accordion title="Example">

```typescript
await vfs.mkdir("cache/images");
```

</Accordion>

Create a directory, including any missing parents.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>path</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Directory path relative to the volume root.</div>
  </div>
</div>

#### <span className="msb-recv">vfs.</span><span className="msb-hn">removeDir()</span>

```typescript
removeDir(path: string): Promise<void>
```

<Accordion title="Example">

```typescript
await vfs.removeDir("cache");
```

</Accordion>

Recursively remove a directory and its contents.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>path</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Directory path relative to the volume root.</div>
  </div>
</div>

#### <span className="msb-recv">vfs.</span><span className="msb-hn">remove()</span>

```typescript
remove(path: string): Promise<void>
```

<Accordion title="Example">

```typescript
await vfs.remove("seed.txt");
```

</Accordion>

Remove a single file.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>path</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">File path relative to the volume root.</div>
  </div>
</div>

#### <span className="msb-recv">vfs.</span><span className="msb-hn">copy()</span>

```typescript
copy(from: string, to: string): Promise<void>
```

<Accordion title="Example">

```typescript
await vfs.copy("seed.txt", "backup/seed.txt");
```

</Accordion>

Copy a file or directory from one path to another.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>from</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Source path relative to the volume root.</div>
  </div>
  <div className="msb-param">
    <div className="msb-param-key"><code>to</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Destination path relative to the volume root.</div>
  </div>
</div>

#### <span className="msb-recv">vfs.</span><span className="msb-hn">rename()</span>

```typescript
rename(from: string, to: string): Promise<void>
```

<Accordion title="Example">

```typescript
await vfs.rename("draft.txt", "final.txt");
```

</Accordion>

Move or rename a file or directory.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>from</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Source path relative to the volume root.</div>
  </div>
  <div className="msb-param">
    <div className="msb-param-key"><code>to</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Destination path relative to the volume root.</div>
  </div>
</div>

#### <span className="msb-recv">vfs.</span><span className="msb-hn">stat()</span>

```typescript
stat(path: string): Promise<FsMetadata>
```

<Accordion title="Example">

```typescript
const meta = await vfs.stat("seed.txt");
console.log(meta.size, meta.kind);
```

</Accordion>

Get metadata for a file or directory.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>path</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Path relative to the volume root.</div>
  </div>
</div>

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><a className="msb-type" href="/sdk/typescript/filesystem#fsmetadata">Promise&lt;FsMetadata&gt;</a></div>
    <div className="msb-param-desc">Kind, size, mode, and timestamps.</div>
  </div>
</div>

#### <span className="msb-recv">vfs.</span><span className="msb-hn">exists()</span>

```typescript
exists(path: string): Promise<boolean>
```

<Accordion title="Example">

```typescript
if (await vfs.exists("seed.txt")) {
  await vfs.remove("seed.txt");
}
```

</Accordion>

Check whether a path exists.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>path</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Path relative to the volume root.</div>
  </div>
</div>

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><span className="msb-type">Promise&lt;boolean&gt;</span></div>
    <div className="msb-param-desc"><code>true</code> if the path exists.</div>
  </div>
</div>

## VolumeHandle


<p className="msb-backref">Returned by <a href="#volume-get">Volume.get()</a> · <a href="#volume-list">Volume.list()</a></p>

A metadata and lifecycle handle for an existing volume.

#### <span className="msb-recv">handle.</span><span className="msb-hn">name</span>

`string`

Volume name

#### <span className="msb-recv">handle.</span><span className="msb-hn">kind</span>

`string`

Volume kind (`"dir"` or `"disk"`)

#### <span className="msb-recv">handle.</span><span className="msb-hn">quotaMib</span>

`number \| null`

Recorded storage quota in MiB

#### <span className="msb-recv">handle.</span><span className="msb-hn">usedBytes</span>

`number`

Current disk usage in bytes

#### <span className="msb-recv">handle.</span><span className="msb-hn">capacityBytes</span>

`number \| null`

Disk capacity in bytes (disk volumes)

#### <span className="msb-recv">handle.</span><span className="msb-hn">diskFormat</span>

`string \| null`

Disk image format (disk volumes)

#### <span className="msb-recv">handle.</span><span className="msb-hn">diskFstype</span>

`string \| null`

Inner disk filesystem (disk volumes)

#### <span className="msb-recv">handle.</span><span className="msb-hn">labels</span>

`ReadonlyArray<readonly [string, string]>`

Metadata labels

#### <span className="msb-recv">handle.</span><span className="msb-hn">createdAt</span>

`Date \| null`

Creation timestamp

#### <span className="msb-recv">handle.</span><span className="msb-hn">fs()</span>

```typescript
fs()
```

Host-side filesystem (live handles only; throws on read-only handles)

<p className="msb-label">Returns</p>

[`VolumeFs`](#volumefs)

#### <span className="msb-recv">handle.</span><span className="msb-hn">remove()</span>

```typescript
remove()
```

Delete this volume (live handles only; throws on read-only handles)

<p className="msb-label">Returns</p>

`Promise<void>`
## VolumeFsReadStream


<p className="msb-backref">Returned by <a href="#volumefs-methods">VolumeFs.readStream()</a></p>

A streaming reader over a volume file. Implements `AsyncIterable<Uint8Array>` and `AsyncDisposable`, so it works with `for await` and `using`.

#### <span className="msb-recv">stream.</span><span className="msb-hn">recv()</span>

```typescript
recv()
```

Read the next chunk; `null` when the stream is exhausted

<p className="msb-label">Returns</p>

`Promise<Uint8Array \| null>`

#### <span className="msb-recv">stream.</span><span className="msb-hn">collect()</span>

```typescript
collect()
```

Drain the stream into a single byte array

<p className="msb-label">Returns</p>

`Promise<Uint8Array>`

#### <span className="msb-recv">stream.</span><span className="msb-hn">[Symbol.asyncIterator]()</span>

```typescript
[Symbol.asyncIterator]()
```

Iterate chunks with `for await`

<p className="msb-label">Returns</p>

`AsyncIterator<Uint8Array>`

#### <span className="msb-recv">stream.</span><span className="msb-hn">[Symbol.asyncDispose]()</span>

```typescript
[Symbol.asyncDispose]()
```

Mark the stream done (for `using`)

<p className="msb-label">Returns</p>

`Promise<void>`

## VolumeFsWriteSink


<p className="msb-backref">Returned by <a href="#volumefs-methods">VolumeFs.writeStream()</a></p>

A streaming writer for a volume file. Implements `AsyncDisposable`, so `await using` closes it automatically.

#### <span className="msb-recv">sink.</span><span className="msb-hn">write()</span>

```typescript
write(data)
```

Write a chunk (`Uint8Array` or UTF-8 string)

<p className="msb-label">Returns</p>

`Promise<void>`

#### <span className="msb-recv">sink.</span><span className="msb-hn">close()</span>

```typescript
close()
```

Flush and close the sink; idempotent

<p className="msb-label">Returns</p>

`Promise<void>`

#### <span className="msb-recv">sink.</span><span className="msb-hn">[Symbol.asyncDispose]()</span>

```typescript
[Symbol.asyncDispose]()
```

Close the sink (for `await using`)

<p className="msb-label">Returns</p>

`Promise<void>`
