Bucket¶
- class storage3._async.file_api.AsyncBucket(id: str, name: str, owner: str, public: bool, created_at: datetime, updated_at: datetime, file_size_limit: int | None, allowed_mime_types: list[str] | None, _client: AsyncClient)¶
Represents a storage bucket.
- async copy(from_path: str, to_path: str) dict[str, str] ¶
Copies an existing file to a new path in the same bucket.
- Parameters:
from_path – The original file path, including the current file name. For example folder/image.png.
to_path – The new file path, including the new file name. For example folder/image-copy.png.
- async create_signed_upload_url(path: str) SignedUploadURL ¶
Creates a signed upload URL.
- Parameters:
path – The file path, including the file name. For example folder/image.png.
- async create_signed_url(path: str, expires_in: int, options: URLOptions = {}) dict[str, str] ¶
- Parameters:
path – file path to be downloaded, including the current file name.
expires_in – number of seconds until the signed URL expires.
options – options to be passed for downloading or transforming the file.
- async create_signed_urls(paths: list[str], expires_in: int, options: CreateSignedURLsOptions = {}) list[dict[str, str]] ¶
- Parameters:
path – file path to be downloaded, including the current file name.
expires_in – number of seconds until the signed URL expires.
options – options to be passed for downloading the file.
- async download(path: str, options: DownloadOptions = {}) bytes ¶
Downloads a file.
- Parameters:
path – The file path to be downloaded, including the path and file name. For example folder/image.png.
- async get_public_url(path: str, options: URLOptions = {}) str ¶
- Parameters:
path – file path, including the path and file name. For example folder/image.png.
- async list(path: str | None = None, options: ListBucketFilesOptions | None = None) list[dict[str, str]] ¶
Lists all the files within a bucket.
- Parameters:
path – The folder path.
options – Search options, including limit, offset, and sortBy.
- async move(from_path: str, to_path: str) dict[str, str] ¶
Moves an existing file, optionally renaming it at the same time.
- Parameters:
from_path – The original file path, including the current file name. For example folder/image.png.
to_path – The new file path, including the new file name. For example folder/image-copy.png.
- async remove(paths: list) list[dict[str, Any]] ¶
Deletes files within the same bucket
- Parameters:
paths – An array or list of files to be deletes, including the path and file name. For example [folder/image.png].
- async upload(path: str, file: BufferedReader | bytes | FileIO | str | Path, file_options: FileOptions | None = None) Response ¶
Uploads a file to an existing bucket.
- Parameters:
path – The relative file path including the bucket ID. Should be of the format bucket/folder/subfolder/filename.png. The bucket must already exist before attempting to upload.
file – The File object to be stored in the bucket. or a async generator of chunks
file_options – HTTP headers.
- async upload_to_signed_url(path: str, token: str, file: BufferedReader | bytes | FileIO | str | Path, file_options: FileOptions | None = None) Response ¶
Upload a file with a token generated from
create_signed_url()
- Parameters:
path – The file path, including the file name
token – The token generated from
create_signed_url()
file – The file contents or a file-like object to upload
file_options – Additional options for the uploaded file
- class storage3._async.file_api.AsyncBucketProxy(id: str, _client: AsyncClient)¶
A bucket proxy, this contains the minimum required fields to query the File API.
- async copy(from_path: str, to_path: str) dict[str, str] ¶
Copies an existing file to a new path in the same bucket.
- Parameters:
from_path – The original file path, including the current file name. For example folder/image.png.
to_path – The new file path, including the new file name. For example folder/image-copy.png.
- async create_signed_upload_url(path: str) SignedUploadURL ¶
Creates a signed upload URL.
- Parameters:
path – The file path, including the file name. For example folder/image.png.
- async create_signed_url(path: str, expires_in: int, options: URLOptions = {}) dict[str, str] ¶
- Parameters:
path – file path to be downloaded, including the current file name.
expires_in – number of seconds until the signed URL expires.
options – options to be passed for downloading or transforming the file.
- async create_signed_urls(paths: list[str], expires_in: int, options: CreateSignedURLsOptions = {}) list[dict[str, str]] ¶
- Parameters:
path – file path to be downloaded, including the current file name.
expires_in – number of seconds until the signed URL expires.
options – options to be passed for downloading the file.
- async download(path: str, options: DownloadOptions = {}) bytes ¶
Downloads a file.
- Parameters:
path – The file path to be downloaded, including the path and file name. For example folder/image.png.
- async get_public_url(path: str, options: URLOptions = {}) str ¶
- Parameters:
path – file path, including the path and file name. For example folder/image.png.
- async list(path: str | None = None, options: ListBucketFilesOptions | None = None) list[dict[str, str]] ¶
Lists all the files within a bucket.
- Parameters:
path – The folder path.
options – Search options, including limit, offset, and sortBy.
- async move(from_path: str, to_path: str) dict[str, str] ¶
Moves an existing file, optionally renaming it at the same time.
- Parameters:
from_path – The original file path, including the current file name. For example folder/image.png.
to_path – The new file path, including the new file name. For example folder/image-copy.png.
- async remove(paths: list) list[dict[str, Any]] ¶
Deletes files within the same bucket
- Parameters:
paths – An array or list of files to be deletes, including the path and file name. For example [folder/image.png].
- async upload(path: str, file: BufferedReader | bytes | FileIO | str | Path, file_options: FileOptions | None = None) Response ¶
Uploads a file to an existing bucket.
- Parameters:
path – The relative file path including the bucket ID. Should be of the format bucket/folder/subfolder/filename.png. The bucket must already exist before attempting to upload.
file – The File object to be stored in the bucket. or a async generator of chunks
file_options – HTTP headers.
- async upload_to_signed_url(path: str, token: str, file: BufferedReader | bytes | FileIO | str | Path, file_options: FileOptions | None = None) Response ¶
Upload a file with a token generated from
create_signed_url()
- Parameters:
path – The file path, including the file name
token – The token generated from
create_signed_url()
file – The file contents or a file-like object to upload
file_options – Additional options for the uploaded file