Quickstart
Install
Section titled “Install”uv add lexigram-storageAdd optional extras for cloud backends:
uv add "lexigram-storage[aws]" # aiobotocore for S3, R2uv add "lexigram-storage[gcp]" # gcloud-aio-storage for GCSuv add "lexigram-storage[azure]" # azure-storage-blob for AzureThe local and memory drivers require no extra dependencies.
Minimal Example
Section titled “Minimal Example”import asynciofrom lexigram import Applicationfrom lexigram.contracts import BlobStoreProtocolfrom lexigram.storage import StorageModule, StorageConfig
async def main() -> None: async with Application.boot( name="storage-demo", modules=[ StorageModule.configure( StorageConfig(default_driver="memory") ), ], ) as app: store = await app.container.resolve(BlobStoreProtocol) info = await store.upload("hello.txt", b"Hello, world!") print(f"Uploaded: {info.path} ({info.size} bytes)") data = await store.download("hello.txt") print(f"Downloaded: {data.decode()}")
asyncio.run(main())For local filesystem:
config = StorageConfig( default_driver="local", drivers={"local": {"root_dir": "./storage"}},)What Just Happened
Section titled “What Just Happened”StorageModule.configure()creates aStorageProviderwith the given config.- The provider registers a
BlobStoreProtocolsingleton in the container. - On boot, it verifies connectivity (health check).
- Your service receives the store via constructor injection.
Next Steps
Section titled “Next Steps”- Guide — mental model, core concepts, common patterns
- How-Tos — task-oriented recipes
- Configuration — every config key with env-var names