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 (Uint8Arrayin TypeScript,bytesin Python)readText()/read_text()returns a UTF-8-decoded string
Download size limit
read() and downloadDir() / download_dir() stop at 2 GiB by default. A
larger download fails with ValidationError. Pass maxBytes / max_bytes to
set a different limit for one call, for example to reject unexpectedly large
files early. For downloadDir(), the limit applies to the size of the ZIP
archive. readText() / read_text() always uses the 2 GiB default.
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 tofiles.* methods must:
- Start with
/- only absolute paths are accepted - Contain no
..segments - no traversal
mkdir -p first.