Managing Sandbox Files

Upload and download files and directories.

Render Sandboxes is in public beta.

APIs, defaults, and limits might change during the beta period.

After you create a sandbox, you can upload files and directories to it and download files it produces. Use these operations to provide code and input data, then retrieve results after executing commands.

Sandbox paths

When specifying a path inside a sandbox:

  • Relative paths resolve from the sandbox's home directory. For example, main.py refers to a file in that directory.
  • Absolute paths resolve from the sandbox's filesystem root. For example, /tmp/output.json refers to a file in /tmp.

Commands also start in the sandbox's home directory, so a file uploaded to main.py is available to a command like python main.py.

Uploading a file

The following example uploads a local file named main.py to the sandbox's home directory:

Call render sandboxes copy with the source and destination paths. Prefix the sandbox path with the sandbox's ID and a colon (:). You can also use cp as an alias for copy.

For a single file, provide the full destination path, including the filename. Uploading to an existing file replaces its contents.

Downloading a file

The following example downloads a file named output.json from the sandbox's home directory:

Reverse the source and destination order to download a file. If the local destination is an existing directory, the file is saved inside it with its original filename.

Transferring directories

You can transfer an entire directory, including its subdirectories. The directory's contents are placed directly inside the destination directory.

For example, if you upload the local directory ./src to your sandbox's ./app directory, a local file at ./src/main.py is uploaded to ./app/main.py inside the sandbox (not ./app/src/main.py).

Uploading a directory

The following example uploads the contents of a local src directory to a src directory inside the sandbox:

Provide a local directory as the source path. The CLI transfers its contents automatically. No recursive flag is required.

Downloading a directory

The following example downloads the contents of an output directory from the sandbox:

The CLI creates the local destination directory if needed and extracts the downloaded contents into it.

Preserving files

A sandbox keeps its files between commands and while suspended. When the sandbox terminates, its filesystem is deleted.

Download any files you need before termination. To reuse the sandbox's filesystem in new sandboxes, capture a snapshot.