Skip to main content
You are currently viewing documentation for version 2.37.1 of the E2B SDK (Python).View the latest version of this page.

AsyncVolume

E2B Volume for persistent storage that can be mounted to sandboxes (async).

create

Create a new volume. Arguments:
  • name: Name of the volume
Returns: An AsyncVolume instance for the new volume

connect

Connect to an existing volume by ID. Arguments:
  • volume_id: Volume ID
Returns: An AsyncVolume instance for the existing volume

destroy

Destroy a volume. Arguments:
  • volume_id: Volume ID

make_dir

Create a directory. Arguments:
  • path: Path to the directory to create
  • uid: User ID of the created directory
  • gid: Group ID of the created directory
  • mode: Mode of the created directory
  • force: Create parent directories if they don’t exist
  • opts: Connection options
Returns: Information about the created directory

exists

Check whether a file or directory exists. Uses get_info under the hood. Returns True if the path exists, False if it does not (404). Other errors are re-raised. Arguments:
  • path: Path to the file or directory
  • opts: Connection options
Returns: True if the path exists, False otherwise

update_metadata

Update file or directory metadata. Arguments:
  • path: Path to the file or directory
  • uid: User ID of the file or directory
  • gid: Group ID of the file or directory
  • mode: Mode of the file or directory
  • opts: Connection options
Returns: Updated entry information

read_file

Read file content. You can pass text, bytes, or stream to format to change the return type. Arguments:
  • path: Path to the file
  • format: Format of the file content—text by default
  • stream_idle_timeout: Idle timeout in seconds for a streamed read (format="stream")—abort if no chunk arrives within this window while reading. Resets on every chunk, so it bounds a stalled stream without limiting total transfer time. Defaults to the request timeout; pass 0 to disable.
  • opts: Connection options
Returns: File content as string, bytes, or async iterator of bytes

write_file

Write content to a file. Writing to a file that doesn’t exist creates the file. Writing to a file that already exists overwrites the file. Arguments:
  • path: Path to the file
  • data: Data to write to the file. Data can be a string, bytes, or IO. File-like objects are streamed in chunks instead of being buffered in memory.
  • uid: User ID of the created file
  • gid: Group ID of the created file
  • mode: Mode of the created file
  • force: Force overwrite of an existing file
  • opts: Connection options
Returns: Information about the written file

remove

Remove a file or directory. Arguments:
  • path: Path to the file or directory to remove
  • opts: Connection options