S3-compatible API with Abstract Object Store in Python (FastAPI).
Project description
BoxDrive
S3-compatible API with Abstract Object Store in Python (FastAPI). Work in progress.
Installation
uv add boxdrive
Quick Start
Basic Usage
- create
main.py:
from boxdrive import create_app
from boxdrive.stores import InMemoryStore
store = InMemoryStore()
app = create_app(store)
- start API in dev mode:
fastapi dev main.py
The API will be available at http://localhost:8000 with automatic documentation at http://localhost:8000/docs.
API Endpoints
The API provides S3-compatible endpoints:
GET /- List bucketsPUT /{bucket}- Create a bucketDELETE /{bucket}- Delete a bucketGET /{bucket}- List objects in a bucketGET /{bucket}/{key}- Get an objectPUT /{bucket}/{key}- Put an objectDELETE /{bucket}/{key}- Delete an object
Creating Custom Object Stores
To create a custom object store implementation, inherit from ObjectStore:
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) -> ObjectInfo: ...
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
Tests
unit
uv run pytest tests/unit
e2e
# start server
uv run fastapi dev examples/inmemory.py --port 8000
export S3_ENDPOINT_URL=http://127.0.0.1:8000
# run e2e tests
uv run run pytest tests/e2e
third_party/s3-tests
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 info.
Code Quality
uv run ruff format .
uv run ruff check . --fix
uv run mypy .
License
Apache 2.0 - see LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file boxdrive-0.0.2.tar.gz.
File metadata
- Download URL: boxdrive-0.0.2.tar.gz
- Upload date:
- Size: 217.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2eb4a828d434ae066cf010616f8f0f455451fec470378566212f70f6ca03d40
|
|
| MD5 |
7746d35d13ed87006805144b1a69739b
|
|
| BLAKE2b-256 |
bafd3f8fa155947feb42df44cb1b712f82902ece6f7f8c16270f50e5011a3c5d
|
File details
Details for the file boxdrive-0.0.2-py3-none-any.whl.
File metadata
- Download URL: boxdrive-0.0.2-py3-none-any.whl
- Upload date:
- Size: 17.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f1b1f1d9046d7e051d97e605016baaa2a23f5eb386fa70ff1261ecdc41599be
|
|
| MD5 |
2a363582e60fbb10c3a515452a764b03
|
|
| BLAKE2b-256 |
63bf35b7205687ab390e1c09c126616c7f9720b35a59cee6c2de86f1e7cc1a19
|