Skip to content
LogoLogo

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

async 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

NameTypeDescription
pathstringAbsolute path inside the sandbox, e.g. /srv/index.html.
dataBodyInitContent to write: string, Blob, ArrayBuffer, ReadableStream, FormData, or URLSearchParams.
options?RequestOptionsPer-request options (signal, timeoutMs, retry, headers).

Returns Promise<void>

Throws

Example

await sandbox.files.upload("/srv/index.html", "<h1>Hello</h1>");

download

async download(path: string, options?: RequestOptions): Promise<ArrayBuffer>

Downloads a file from the sandbox as raw bytes.

Parameters

NameTypeDescription
pathstringAbsolute path inside the sandbox.
options?RequestOptionsPer-request options.

Returns Promise<ArrayBuffer>

Throws

Example

const buf = await sandbox.files.download("/etc/os-release");
console.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 with CREATEOS_SANDBOX_BASE_URL)
  • Auth: API key via the apiKey option or CREATEOS_SANDBOX_API_KEY

See also

  • Sandbox: the parent handle and all other per-sandbox operations.
  • Client: createSandbox, getSandbox, listSandboxes, and the sub-API namespaces.
  • Errors: full error class hierarchy.
  • Types: all wire types and option interfaces.