Skip to content

FileManager

Reads, writes, uploads, and downloads files for a runtime.

Sync · Async counterpart: AsyncFileManager

class FileManager(_SdkOwnedHandle):

This type is created by the SDK; do not construct it directly.

manager = runtime.files

Read a file from the runtime as bytes.

def read(path: str, max_bytes: int | None = None) -> bytes
NameTypeDefaultDescription
pathstrPath inside the runtime.
max_bytesint | NoneNoneMaximum number of bytes to return.
  • bytes

Write bytes or text to a runtime file.

def write(path: str, content: bytes | str, executable: bool = False) -> None
NameTypeDefaultDescription
pathstrAbsolute destination path inside the runtime.
contentbytes | strText or binary content to write.
executableboolFalseMark the resulting file executable.
>>> runtime.files.write(
... "/workspace/hello.sh", "#!/bin/sh\necho hello\n", executable=True
... )
>>> runtime.exec(["/workspace/hello.sh"]).stdout_text
'hello\n'

Upload a local file or directory to the runtime.

def upload(src: str, dst: str) -> None
NameTypeDefaultDescription
srcstrLocal source path.
dststrLocal destination path.

Download a runtime file or directory locally.

def download(src: str, dst: str) -> None
NameTypeDefaultDescription
srcstrLocal source path.
dststrLocal destination path.