sandbox.files to work with files inside a sandbox. Every path argument
names a location inside the sandbox; it is the data that moves between the two
machines. write(path, data) sends local bytes or text to a sandbox path, and
read(path) returns a sandbox file’s content to your program.
write() creates missing parent directories. It replaces the entire file if that
path already exists.
Upload and download
Usepathlib.Path to read a local file and send its contents to the sandbox:
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():
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: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.
Upload a project directory
files.write() is one file per call. To ship a whole directory, pack it locally
and unpack it in the sandbox with one command, sending the archive through
standard input:
cat >> pattern above
and untar it, or download it inside the sandbox from storage you control.
Exclude virtual environments and build artifacts before packing.