write_file() method allows you to create or overwrite files inside your sandbox’s isolated filesystem.It supports both text and binary content, making it flexible for handling scripts, configuration files, and assets such as images, JSON files, or compiled binaries. All file paths must begin with either the tilde (
~) shortcut or the absolute sandbox path /home/damner/code.
write_file(path: str, content: Union[str, bytes]) -> None
Description:Writes a file to the sandbox filesystem. Supports both text (
str) and binary (bytes) content.Automatically creates directories if they don’t exist.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
path | str | Yes | File path (must start with ~ or /home/damner/code) |
content | str or bytes | Yes | File content (text string or binary data) |
Returns:
None : Resolves when the file write operation is complete.
Examples
