FileSystem
File operations inside the sandbox.
FileSystem performs file operations inside a sandbox via the toolbox. Obtain it as sandbox.fs. All paths are paths inside the sandbox. See the files guide for a task-oriented walkthrough.
upload_file()
Uploads bytes to a path inside the sandbox. The default timeout is generous (30 minutes) to accommodate large uploads.
| Parameter | Type | Default | Description |
|---|---|---|---|
content | bytes | — | File contents. |
remote_path | str | — | Destination path inside the sandbox. |
timeout | int | 1800 | Request timeout in seconds. |
download_file()
Downloads a file's bytes from the sandbox.
Returns: the raw file contents as bytes.
list_files()
Lists the entries of a directory.
Returns: a list of file-info dicts (name, size, directory flag, mode, timestamps).
get_file_details()
Fetches info for a single file or directory.
create_folder()
Creates a folder at the given path with the given permission mode.
| Parameter | Type | Default | Description |
|---|---|---|---|
path | str | — | Directory to create. |
mode | str | — | Octal permission string, e.g. "755". |
delete_file()
Deletes a file at the given path.
move_files()
Moves (renames) a file or directory from source to destination.
find_files()
Searches for text inside files under a path — grep-style. Compare search_files(), which matches file names.
Returns: a list of match dicts (file, line, content).
search_files()
Searches for files whose names match a pattern under a path.
Returns: a dict with a files list of matching paths.
replace_in_files()
Replaces text across a set of files in one call.
| Parameter | Type | Default | Description |
|---|---|---|---|
files | List[str] | — | Paths of files to edit. |
pattern | str | — | Pattern to replace. |
new_value | str | — | Replacement text. |
Returns: a list of per-file result dicts (file, success/error).
set_file_permissions()
Sets permissions and/or ownership on a file. Any subset of mode, owner, and group may be provided.
| Parameter | Type | Default | Description |
|---|---|---|---|
path | str | — | Target file. |
mode | str | None | Octal permission string, e.g. "644". |
owner | str | None | New owner user. |
group | str | None | New owner group. |