Skip to main content
Use sandbox.files to work with files inside a sandbox. Paths refer to the sandbox’s filesystem, not your computer.
write() creates missing parent directories. It replaces the entire file if that path already exists.

Upload and download

Use pathlib.Path to read a local file and send its contents to the sandbox:
After your application creates a result, save it to your computer:
Use read() for text and read_bytes() for binary files. Uploads support up to 4 MiB per call. Text reads support approximately 16 MiB, and binary reads support approximately 12 MiB. Use another transfer method for larger files.

Manage paths

Remove a file or directory with remove():
Removing a directory also removes its contents.

Transfer larger files

For large inputs, download the file from a URL inside the sandbox when possible. You can also send chunks through a command’s standard input. This example uploads a local file without replacing earlier chunks:
Use cat >> for appending; multiple files.write() calls to the same path would overwrite each other. Verify the size or checksum after a transfer. For large outputs, upload from the sandbox to storage you control, then download from there.

Keep or remove files

Files persist between commands and across archive/unarchive. To retain work before deleting the sandbox, download the files or save a durable snapshot. When you are finished: