Skip to main content
Use sandbox.files to move data in and out of a sandbox. The SDK handles data-plane routing and authentication transparently.
Using AsyncSandbox? The same files methods are there, awaitable.

Write binary content

write() accepts strings or raw bytes. Parent directories are created automatically.

Read as bytes or text

  • read() returns raw bytes (Uint8Array in TypeScript, bytes in Python)
  • readText() / read_text() returns a UTF-8-decoded string

Download a directory as a zip

downloadDir() / download_dir() exports a whole directory as a ZIP archive — useful for pulling out logs, build artifacts, or results in one call. It returns the raw zip bytes; large directories can exceed the default 30s timeout, so pass a longer timeoutMs / timeout when needed.

Path rules

Paths passed to files.* methods must:
  • Start with / - only absolute paths are accepted
  • Contain no .. segments - no traversal
Parent directories are created automatically on write - you don’t need to mkdir -p first.

Errors

See the files reference and the full error hierarchy.