AsyncFileManager
Reads, writes, uploads, and downloads runtime files asynchronously.
Async · Sync counterpart:
FileManager
AsyncFileManager declaration
Section titled “AsyncFileManager declaration”class AsyncFileManager(_SdkOwnedHandle):AsyncFileManager access
Section titled “AsyncFileManager access”This type is created by the SDK; do not construct it directly.
manager = runtime.filesAsyncFileManager methods
Section titled “AsyncFileManager methods”read()
Section titled “read()”Read a file from the runtime as bytes.
async 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.
async 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”>>> await runtime.files.write(... "/workspace/hello.sh", "#!/bin/sh\necho hello\n", executable=True... )>>> result = await runtime.exec(["/workspace/hello.sh"])>>> result.stdout_text'hello\n'upload()
Section titled “upload()”Asynchronously stream a local file or directory to the runtime.
async def upload(src: str, dst: str) -> NoneParameters
Section titled “Parameters”| Name | Type | Default | Description |
|---|---|---|---|
src |
str |
— |
Local file or directory path. |
dst |
str |
— |
Destination path inside the runtime. |
Examples
Section titled “Examples”>>> await runtime.files.upload("./project", "/workspace/project")download()
Section titled “download()”Asynchronously stream a runtime file or directory locally.
async def download(src: str, dst: str) -> NoneParameters
Section titled “Parameters”| Name | Type | Default | Description |
|---|---|---|---|
src |
str |
— |
Source file or directory inside the runtime. |
dst |
str |
— |
Local destination path. |
Examples
Section titled “Examples”>>> await runtime.files.download("/workspace/dist", "./artifacts/")