Skip to main content

BoxDrive

github ci

S3-compatible API with Abstract Object Store in Python (FastAPI). Work in progress.

Built-in stores

  • InMemoryStore
  • GitlabStore (with some limitations)

Quick Start

  1. Install boxdrive from PyPI using your preferred package manager:
uv add boxdrive
  1. Create main.py:
from boxdrive import create_app
from boxdrive.stores import InMemoryStore

store = InMemoryStore()
app = create_app(store)
  1. Start the API (in development mode):
fastapi dev main.py

By default, Swagger UI will be available at http://localhost:8000/docs

API Endpoints

The API exposes the following S3-compatible endpoints:

  • GET / - List buckets
  • PUT /{bucket} - Create a bucket
  • DELETE /{bucket} - Delete a bucket
  • GET /{bucket} - List objects in a bucket
  • GET /{bucket}/{key} - Get an object
  • PUT /{bucket}/{key} - Put an object
  • DELETE /{bucket}/{key} - Delete an object

Creating Custom Object Stores

To use a custom object store, implement the ObjectStore interface and provide an instance to create_app:

from boxdrive import (
    BucketInfo,
    BucketName,
    ContentType,
    Key,
    ListObjectsInfo,
    ListObjectsV2Info,
    MaxKeys,
    Object,
    ObjectInfo,
    ObjectStore,
)

class MyCustomStore(ObjectStore):
    async def list_buckets(self) -> list[BucketInfo]: ...
    async def create_bucket(self, bucket_name: BucketName) -> None: ...
    async def delete_bucket(self, bucket_name: BucketName) -> None: ...
    async def get_object(self, bucket_name: BucketName, key: Key) -> Object: ...
    async def put_object(
        self, bucket_name: BucketName, key: Key, data: bytes, content_type: ContentType | None = None
    ) -> ObjectInfo: ...
    async def delete_object(self, bucket_name: BucketName, key: Key) -> None: ...
    async def head_object(self, bucket_name: BucketName, key: Key) -> ObjectInfo: ...
    async def list_objects(
        self,
        bucket_name: BucketName,
        *,
        prefix: Key | None = None,
        delimiter: str | None = None,
        max_keys: MaxKeys = 1000,
        marker: Key | None = None,
    ) -> ListObjectsInfo: ...
    async def list_objects_v2(
        self,
        bucket_name: BucketName,
        *,
        continuation_token: Key | None = None,
        delimiter: str | None = None,
        encoding_type: str | None = None,
        max_keys: MaxKeys = 1000,
        prefix: Key | None = None,
        start_after: Key | None = None,
    ) -> ListObjectsV2Info: ...

Use exceptions from boxdrive.exceptions (e.g., NoSuchBucket, NoSuchKey) in your custom store implementation.

Development

API

  1. Start the monitoring pipeline:
docker compose -f docker-compose-monitoring.yaml up --detach --wait

Telemetry data will be saved in ClickHouse, which is exposed at localhost:8123.

  1. Start the API:
export OTEL_EXPORTER_HTTP_ENDPOINT=http://localhost:4318
uv run fastapi dev examples/inmemory.py

Tests

Unit tests

uv run pytest tests/unit

End-to-end (e2e) tests

The API should be running in the background.

export S3_ENDPOINT_URL=http://127.0.0.1:8000
uv run run pytest tests/e2e

Third-party S3 tests

The API should be running in the background.

cd tests/third_party/s3-tests
export S3TEST_CONF=s3tests.conf
uv run tox -- s3tests_boto3/functional/test_s3.py -m boxdrive

See tests/third_party/s3-tests/boxdrive.md for additional information.

Code Quality

uv run ruff format .
uv run ruff check . --fix
uv run mypy .

License

Apache 2.0 – see the LICENSE file for details.

Release files for boxdrive 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for boxdrive 0.0.4
File Size Uploaded
boxdrive-0.0.4.tar.gz 209.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for boxdrive 0.0.4
File Interpreter ABI Platform
boxdrive-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 234.1 kB

Release files / boxdrive-0.0.4.tar.gz

Download URL boxdrive-0.0.4.tar.gz
Size 209.4 kB
Tags Source
SHA-256 checksum
How to use checksums
abd0a97e32fba3cbcfbfd259823b136ed94c27ca77671d364d0789f58f5e9fde
BLAKE2b-256 checksum
How to use checksums
35674cd8076f4bef32fceba9da66b0494644b119fb4b3b27c1857633c5289e09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.14

Release files / boxdrive-0.0.4-py3-none-any.whl

Download URL boxdrive-0.0.4-py3-none-any.whl
Size 24.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
606f44d4696b0d1124ff45c12868cc6f665ad1c04105199ff47351db2c29fcc2
BLAKE2b-256 checksum
How to use checksums
c489fac2e4c935621dac3489dfbfe998fb2523ac8b8e04d5492b08c06122349a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.14

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release 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