> ## Documentation Index
> Fetch the complete documentation index at: https://opensandbox-oc-s-762ac928075c46d2828bcb22.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Filesystem

> Read, write, and manage files

Accessed via `sandbox.files`.

## `sandbox.files.read(path)`

Read a file as a UTF-8 string. [HTTP API →](/api-reference/files/read)

<ParamField body="path" type="string" required>
  Absolute path to the file
</ParamField>

**Returns:** `Promise<string>`

***

## `sandbox.files.readBytes(path)`

Read a file as raw bytes.

<ParamField body="path" type="string" required>
  Absolute path to the file
</ParamField>

**Returns:** `Promise<Uint8Array>`

***

## `sandbox.files.write(path, content)`

Write content to a file. [HTTP API →](/api-reference/files/write)

<ParamField body="path" type="string" required>
  Absolute path for the destination file
</ParamField>

<ParamField body="content" type="string | Uint8Array" required>
  File content
</ParamField>

**Returns:** `Promise<void>`

***

## `sandbox.files.list(path?)`

List directory contents. [HTTP API →](/api-reference/files/list-directory)

<ParamField body="path" type="string" default="/">
  Directory path
</ParamField>

**Returns:** `Promise<EntryInfo[]>`

***

## `sandbox.files.makeDir(path)`

Create a directory (recursive). [HTTP API →](/api-reference/files/mkdir)

<ParamField body="path" type="string" required>
  Directory path
</ParamField>

**Returns:** `Promise<void>`

***

## `sandbox.files.remove(path)`

Delete a file or directory. [HTTP API →](/api-reference/files/delete)

<ParamField body="path" type="string" required>
  Path to remove
</ParamField>

**Returns:** `Promise<void>`

***

## `sandbox.files.readStream(path)`

Stream a file as a `ReadableStream`. Avoids buffering the entire file in memory — ideal for large files (50MB+).

<ParamField body="path" type="string" required>
  Absolute path to the file
</ParamField>

**Returns:** `Promise<ReadableStream<Uint8Array>>`

***

## `sandbox.files.writeStream(path, stream)`

Stream content to a file. Accepts a `ReadableStream` or `Uint8Array` without buffering an extra copy in memory.

<ParamField body="path" type="string" required>
  Absolute path for the destination file
</ParamField>

<ParamField body="stream" type="ReadableStream<Uint8Array> | Uint8Array" required>
  File content as a stream or byte array
</ParamField>

**Returns:** `Promise<void>`

***

## `sandbox.files.exists(path)`

Check if a path exists. Client-side wrapper — attempts a read and returns `false` on error.

<ParamField body="path" type="string" required>
  Path to check
</ParamField>

**Returns:** `Promise<boolean>`

***

## Types

<Accordion title="EntryInfo">
  ```typescript theme={null}
  interface EntryInfo {
    name: string;
    isDir: boolean;
    path: string;
    size: number;
  }
  ```
</Accordion>
