Sandbox Files
SandboxFiles handles raw file transfer between your process and the sandbox filesystem. Reach it via sandbox.files on a Sandbox handle.
Every method also throws CreateosSandboxServerError on a 5xx response and CreateosSandboxConnectionError on network failure.
upload
TypeScript1async upload(path: string, data: BodyInit, options?: RequestOptions): Promise<void>
Uploads raw bytes to an absolute path inside the sandbox. The destination directories must already exist. Any existing file at path is overwritten.
Parameters
| Name | Type | Description |
|---|---|---|
path | string | Absolute path inside the sandbox, e.g. /srv/index.html. |
data | BodyInit | Content to write — string, Blob, ArrayBuffer, ReadableStream, FormData, or URLSearchParams. |
options? | RequestOptions | Per-request options (signal, timeoutMs, retry, headers). |
Returns Promise<void>
Throws
CreateosSandboxValidationError— path invalid or body rejected.CreateosSandboxNotFoundError— sandbox no longer exists.CreateosSandboxAuthError— API key missing or revoked.CreateosSandboxPermissionError— sandbox belongs to another tenant.CreateosSandboxTimeoutError— per-request timeout elapsed.
Example
TypeScript1await sandbox.files.upload("/srv/index.html", "<h1>Hello</h1>");
download
TypeScript1async download(path: string, options?: RequestOptions): Promise<ArrayBuffer>
Downloads a file from the sandbox as raw bytes.
Parameters
| Name | Type | Description |
|---|---|---|
path | string | Absolute path inside the sandbox. |
options? | RequestOptions | Per-request options. |
Returns Promise<ArrayBuffer>
Throws
CreateosSandboxNotFoundError— sandbox or path does not exist.CreateosSandboxValidationError— path invalid.CreateosSandboxAuthError— API key missing or revoked.CreateosSandboxPermissionError— sandbox belongs to another tenant.CreateosSandboxTimeoutError— per-request timeout elapsed.
Example
TypeScript1const buf = await sandbox.files.download("/etc/os-release");2console.log(new TextDecoder().decode(buf));
At a glance
- Package:
@nodeops-createos/sandbox(npm) - Import:
import { createClient } from "@nodeops-createos/sandbox" - Base URL:
https://api.sb.createos.sh— override withCREATEOS_SANDBOX_BASE_URL - Auth: API key via the
apiKeyoption orCREATEOS_SANDBOX_API_KEY