Methods
read
Read a file from the bucket.
def read(key: str) -> bytes
Parameters
The key/path of the file to read
Returns
The file contents as bytes
Example:
content = client.image.read("path/to/file.txt")
print(content.decode('utf-8'))
write
Write a file to the bucket.
def write(key: str, data: bytes) -> None
Parameters
The key/path where the file should be stored
The file contents as bytes
Example:
client.image.write("path/to/file.txt", b"Hello, World!")
delete
Delete a file from the bucket.
def delete(key: str) -> None
Parameters
The key/path of the file to delete
Example:
client.image.delete("path/to/file.txt")
list
List files in the bucket with an optional prefix filter.
def list(prefix: str = "") -> List[str]
Parameters
Filter results to keys starting with this prefix
Returns
List of file keys matching the prefix
Example:
# List all files
all_files = client.image.list()
# List files in a specific directory
docs = client.image.list("documents/")
exists
Check if a file exists in the bucket.
def exists(key: str) -> bool
Parameters
The key/path of the file to check
Returns
True if the file exists, False otherwise
Example:
if client.image.exists("file.txt"):
config = client.image.read("file.txt")
Presigned URLs
Generate presigned URLs for secure file access without exposing credentials.
def get_download_url(key: str, options: Optional[PresignUrlOptions] = None) -> str
def get_upload_url(key: str, options: Optional[PresignUrlOptions] = None) -> str
Parameters
options
PresignUrlOptions
default:"PresignUrlOptions(expiry=300)"
Configuration with expiry in seconds
Returns
The presigned URL for the file
Example:
# Download URL (default 5 minute expiry)
download_url = client.image.get_download_url("file.txt")
# Upload URL with custom expiry (1 hour)
upload_url = client.image.get_upload_url("file.txt",
PresignUrlOptions(expiry=3600))