FileManager
Reads, writes, uploads, and downloads files for a runtime.
Sync · Async counterpart:
AsyncFileManager
FileManager declaration
Section titled “FileManager declaration”class FileManager(_SdkOwnedHandle):FileManager access
Section titled “FileManager access”This type is created by the SDK; do not construct it directly.
manager = runtime.filesFileManager methods
Section titled “FileManager methods”read()
Section titled “read()”Read a file from the runtime as bytes.
def read(path: str, max_bytes: int | None = None) -> bytesParameters
Section titled “Parameters”| Name | Type | Default | Description |
|---|---|---|---|
path | str | — | Path inside the runtime. |
max_bytes | int | None | None | Maximum number of bytes to return. |
Returns
Section titled “Returns”bytes
write()
Section titled “write()”Write bytes or text to a runtime file.
def write(path: str, content: bytes | str, executable: bool = False) -> NoneParameters
Section titled “Parameters”| Name | Type | Default | Description |
|---|---|---|---|
path | str | — | Absolute destination path inside the runtime. |
content | bytes | str | — | Text or binary content to write. |
executable | bool | False | Mark the resulting file executable. |
Examples
Section titled “Examples”>>> runtime.files.write(... "/workspace/hello.sh", "#!/bin/sh\necho hello\n", executable=True... )>>> runtime.exec(["/workspace/hello.sh"]).stdout_text'hello\n'upload()
Section titled “upload()”Upload a local file or directory to the runtime.
def upload(src: str, dst: str) -> NoneParameters
Section titled “Parameters”| Name | Type | Default | Description |
|---|---|---|---|
src | str | — | Local source path. |
dst | str | — | Local destination path. |
download()
Section titled “download()”Download a runtime file or directory locally.
def download(src: str, dst: str) -> NoneParameters
Section titled “Parameters”| Name | Type | Default | Description |
|---|---|---|---|
src | str | — | Local source path. |
dst | str | — | Local destination path. |