Skip to main content

byoc

Python SDK for BYOC (Bring Your Own Cloud): a provider-agnostic storage layer for building applications on top of cloud storage your users already own.

Part of the BYOC monorepo. Peer implementation of @byoc/core on npm.

Status: v0.2.0. Every adapter is validated against a live server. Not yet on PyPI.

Why

Instead of paying to host every user's files on your own S3 bucket, BYOC lets your application read and write storage the user already owns: their Google Drive, their company's Nextcloud, their own R2 bucket.

FastAPI / Django / Celery
   │
   ├── PostgreSQL  → users, jobs, metadata pointers
   │
   └── byoc        → the actual PDFs, images, audio, model artifacts
           │
           └── the user's own cloud

Use Postgres for your application data. Use BYOC for their files.

Install

pip install byoc-storage

The distribution is named byoc-storage because byoc on PyPI belongs to an unrelated CLI framework. The import name is still byoc:

import byoc

If you also depend on the unrelated byoc CLI framework, do not install both into the same environment: they share the byoc import name and will shadow each other.

Usage

import os
from byoc import AsyncBYOC
from byoc.providers.s3 import S3CompatibleProvider

storage = AsyncBYOC(
    provider=S3CompatibleProvider(
        endpoint="https://<account_id>.r2.cloudflarestorage.com",
        bucket="user-assets",
        region="auto",
        access_key_id=os.environ["R2_ACCESS_KEY_ID"],
        secret_access_key=os.environ["R2_SECRET_ACCESS_KEY"],
    )
)

async with storage:
    await storage.write_text("documents/welcome.md", "# Hello from BYOC!")
    content = await storage.read_text("documents/welcome.md")

Multiple providers and migration

storage = AsyncBYOC(providers=[drive, r2, nextcloud], default_provider_id="s3-compatible")

storage.use_provider("webdav")
await storage.write_bytes("images/banner.png", data)

report = await storage.migrate(
    source="s3-compatible",
    target="webdav",
    paths=["documents/report.pdf"],
    on_progress=lambda p: print(f"{p.current_file} ({p.percentage}%)"),
)

report.files_partial counts files that reached the target but whose source cleanup failed. The transfer is done, so retrying those would re-upload for nothing.

Async only for now. A synchronous facade for Celery, Django, and scripts is planned but not yet implemented; use asyncio.run() in the meantime.

Google Drive

Drive needs a Google Cloud OAuth client. See Google Drive OAuth Setup, then verify your setup with:

.venv/bin/python scripts/validate_gdrive_live.py

Cross-SDK compatibility

This SDK and the TypeScript SDK are peer implementations of the same contract. Both run against the shared conformance vectors in spec/fixtures, so a file written by a Next.js frontend can be read by a FastAPI backend, including client-side encrypted files, whose envelope format is byte-identical across both.

Development

python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

pytest              # unit + conformance suite
mypy src            # strict type checking
ruff check .        # lint

Without activating, call the venv binaries directly: .venv/bin/pytest, .venv/bin/mypy src, .venv/bin/ruff check .

License

Apache-2.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

byoc_storage-0.2.0.tar.gz (65.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

byoc_storage-0.2.0-py3-none-any.whl (57.0 kB view details)

Uploaded Python 3

File details

Details for the file byoc_storage-0.2.0.tar.gz.

File metadata

  • Download URL: byoc_storage-0.2.0.tar.gz
  • Upload date:
  • Size: 65.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for byoc_storage-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6b31d103c036443982d384d73a551d66c49bdbc0368c778def710c39951aa1b5
MD5 a0ebb9cef3f905887c7e1a7f8aca3b4c
BLAKE2b-256 9e35bb18d11829d6f1193000b3dc86189c699780a6d23cfdac7a3525b5a6b260

See more details on using hashes here.

File details

Details for the file byoc_storage-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: byoc_storage-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 57.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for byoc_storage-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 45d9e77171899d5aa9a99c8015ab51accaf123aad482daf39db4f39311ad8942
MD5 c932b9db44adc6ca65701e05d6cd5571
BLAKE2b-256 3cfd4c0ec0d7e6dda543fed03296cf9ac67be46f02c46a2584927320bc7989c6

See more details on using hashes here.

Release history Release notifications | RSS feed

0.4.0

2 files

0.3.0

2 files

This release

0.2.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page