This release is a pre-release and may not be stable for production use.
storage3
Python client for Supabase Storage. Most users reach it through the
Supabase client
as client.storage, which sets the headers for you.
Installation
Needs an HTTP client adapter, such as httpx:
uv add storage3 "supabase_utils[httpx]"
# or
pip install storage3 "supabase_utils[httpx]"
Supabase Service Compatibility
Only the latest Storage release is guaranteed to work. Older releases are supported on a best-effort basis. If you self-host, upgrade Storage when you upgrade this package.
| Feature | Minimum Storage version |
|---|---|
list() |
v1.19.0 |
Paging, search and sort in list_buckets() |
v1.25.0 |
Older releases ignore the list_buckets() arguments and return every bucket.
Usage
The client takes the storage URL, the headers to send and the HTTP session. Leaving the context manager closes the session:
import asyncio
from httpx import AsyncClient
from storage3 import AsyncStorageClient
from supabase_utils.http.adapters.httpx import AsyncHttpxSession
url = "https://<project_ref>.supabase.co/storage/v1/"
key = "<your api key>"
headers = {"apikey": key, "Authorization": f"Bearer {key}"}
async def main() -> None:
session = AsyncHttpxSession(AsyncClient())
async with AsyncStorageClient(url, headers, session) as storage_client:
print(await storage_client.list_buckets())
asyncio.run(main())
SyncStorageClient with an HttpxSession works the same way without await.
The examples below use the async storage_client.
Upload
Set the MIME type with content_type. It defaults to
text/plain;charset=UTF-8. A path, an open binary file or an iterator over
bytes is streamed, so a large file is never held in memory:
from pathlib import Path
await storage_client.from_("bucket").upload(
"folder/file.png", Path("file.png"), content_type="image/png"
)
Resumable upload
resumable_upload sends a large file in 6 MiB chunks with the
tus protocol. A failed upload continues from the last chunk.
The store keeps the upload URL, so the upload can continue after a restart:
import shelve
from storage3 import ResumableUploadPausedError
with shelve.open("uploads") as store:
upload = storage_client.from_("bucket").resumable_upload(
"videos/intro.mp4", "intro.mp4", content_type="video/mp4", store=store
)
try:
response = await upload.run()
except ResumableUploadPausedError:
print(f"Paused after {upload.offset} of {upload.size} bytes")
upload.pause() stops after the current chunk and run() continues.
await upload.cancel() deletes the upload on the server.
Streaming download
download_stream gives the status and headers first, then the body as it
arrives. write_to replaces the file only once the whole body arrived.
read(max_bytes=...) raises StorageDownloadTooLargeError past the cap:
bucket = storage_client.from_("bucket")
async with bucket.download_stream("videos/intro.mp4") as download:
print(download.status, download.content_length)
await download.write_to("intro.mp4")
Progress
upload, update, upload_to_signed_url, download and download_stream
take an on_progress callback. The total is None when it is unknown. The
count restarts on a retry, and the callback can run in a worker thread:
from pathlib import Path
def on_progress(moved: int, total: int | None) -> None:
print(f"{moved} of {total or '?'} bytes")
await storage_client.from_("bucket").upload(
"videos/intro.mp4", Path("intro.mp4"), on_progress=on_progress
)
Byte ranges
download and download_stream take an offset and a length. If the server
ignores the range, download raises StorageRangeIgnoredError:
first_bytes = await storage_client.from_("bucket").download(
"videos/intro.mp4", length=512
)
To resume a download, pass the size of the partial file as offset and
resume=True to write_to. Pass the etag of the first download as
if_match, so a changed file raises StorageApiError with the code
PreconditionFailed instead of mixing two versions:
from pathlib import Path
async def resume(partial: Path, etag: str) -> None:
async with storage_client.from_("bucket").download_stream(
"videos/intro.mp4", offset=partial.stat().st_size, if_match=etag
) as download:
await download.write_to(partial, resume=True)
File versions
A bucket with versioning_status="ENABLED" keeps old versions when a file is
overwritten or removed. List them with noncurrent_versions and the delete
markers with delete_markers:
await storage_client.create_bucket("documents", versioning_status="ENABLED")
documents = storage_client.from_("documents")
page = await documents.list("reports/", noncurrent_versions="include")
for entry in page.objects:
print(entry.name, entry.version, entry.archived_at)
Pass version_id to read a version, or source_version_id to copy or move
one. Moving a version to its own path restores it. remove takes a
FileVersion to delete one version:
from storage3.types import FileVersion
documents = storage_client.from_("documents")
old = await documents.download("reports/q3.pdf", version_id="<version id>")
await documents.move(
"reports/q3.pdf", "reports/q3.pdf", source_version_id="<version id>"
)
await documents.remove([FileVersion("reports/q3.pdf", "<version id>")])
versioning_status="SUSPENDED" stops keeping new versions. A bucket cannot go
back to DISABLED.
Metadata
Release files for storage3 3.0.0a2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| storage3-3.0.0a2.tar.gz | 36.6 kB | Without provenance | Details for storage3-3.0.0a2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| storage3-3.0.0a2-py3-none-any.whl | Python 3 | none | any | Details for storage3-3.0.0a2-py3-none-any.whl |
Total release size: 77.8 kB
Release files / storage3-3.0.0a2.tar.gz
| Download URL | storage3-3.0.0a2.tar.gz |
|---|---|
| Size | 36.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
76cfb36d0645a2235f510c408c800850554f4d4498e5258eb8582d6711608914
|
|
BLAKE2b-256 checksum How to use checksums |
bd667b3d226763275d13b71695d81532ec22370b6afe4c94b0a9e397c01d337a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.12 {"installer":{"name":"uv","version":"0.13.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / storage3-3.0.0a2-py3-none-any.whl
| Download URL | storage3-3.0.0a2-py3-none-any.whl |
|---|---|
| Size | 41.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a932004d954805b0beb5db2c710a9537321929a35427097059c8af3e40f84f13
|
|
BLAKE2b-256 checksum How to use checksums |
53b2a49fc978cc49236938c2cd2e8dd1933a8232dc4cf083b0d20bd9ab09c4db
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.12 {"installer":{"name":"uv","version":"0.13.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for storage3 3.0.0a2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.