Skip to main content

lexigram-storage

Unified blob storage abstraction for Lexigram Framework — S3, GCS, Azure Blob, and local filesystem


Overview

lexigram-storage provides a unified BlobStore interface over Amazon S3, Google Cloud Storage, Azure Blob Storage, Cloudflare R2, and local disk — with signed URLs, streaming uploads, content-type negotiation, and server-side encryption. All services are wired via StorageProvider, which registers the blob store protocol with the DI container.


Full documentation: docs.lexigram.dev

Install

uv add lexigram-storage
# Optional extras
uv add "lexigram-storage[s3]"     # Amazon S3 (aiobotocore)
uv add "lexigram-storage[gcp]"    # Google Cloud Storage
uv add "lexigram-storage[azure]"  # Azure Blob Storage

Quick Start

from lexigram import Application
from lexigram.di.module import Module, module

# Import the module from the package
from lexigram.storage import StorageModule
from lexigram.storage.config import StorageConfig, StorageLocalConfig


@module(
    imports=[
        StorageModule.configure(
            StorageConfig(drivers={"local": StorageLocalConfig(root_dir="./storage")})
        )
    ]
)
class AppModule(Module):
    pass


async with Application.boot(modules=[AppModule]) as app:
    # use app.container to resolve services
    ...

Configuration

Zero-config usage: Call StorageModule.configure() with no arguments to use defaults.

Option 1 — YAML file

# application.yaml
storage:
  default_driver: "s3"
  drivers:
    s3:
      bucket: "my-app-uploads"
      region: "us-east-1"
      access_key: "${AWS_ACCESS_KEY_ID}"
      secret_key: "${AWS_SECRET_ACCESS_KEY}"

Option 2 — Profiles + Environment Variables (recommended)

export LEX_STORAGE__ENABLED=true
# Environment variables for each field

Option 3 — Python

from lexigram.storage.config import StorageConfig
from lexigram.storage import StorageModule

config = StorageConfig(default_driver="s3", ...)
StorageModule.configure(config)

Config reference

Field Default Env var Description
default_driver "local" LEX_STORAGE__DEFAULT_DRIVER Active driver: s3, gcs, azure, r2, local, memory
drivers.s3.bucket LEX_STORAGE__DRIVERS__S3__BUCKET S3 bucket name
drivers.s3.region "us-east-1" LEX_STORAGE__DRIVERS__S3__REGION AWS region
drivers.s3.access_key LEX_STORAGE__DRIVERS__S3__ACCESS_KEY AWS access key ID
drivers.s3.secret_key LEX_STORAGE__DRIVERS__S3__SECRET_KEY AWS secret access key
drivers.s3.endpoint_url null LEX_STORAGE__DRIVERS__S3__ENDPOINT_URL Override endpoint (MinIO, LocalStack)
drivers.gcs.bucket LEX_STORAGE__DRIVERS__GCS__BUCKET GCS bucket name
drivers.gcs.credentials_path LEX_STORAGE__DRIVERS__GCS__CREDENTIALS_PATH Path to service account JSON
drivers.azure.account_name LEX_STORAGE__DRIVERS__AZURE__ACCOUNT_NAME Azure storage account name
drivers.azure.container LEX_STORAGE__DRIVERS__AZURE__CONTAINER Azure blob container
drivers.local.root_dir LEX_STORAGE__DRIVERS__LOCAL__ROOT_DIR Root directory for local storage
service.max_file_size_mb 100 LEX_STORAGE__SERVICE__MAX_FILE_SIZE_MB Maximum upload size in MB

Module Factory Methods

Method Description
StorageModule.configure(config, enable_encryption) Configure with explicit StorageConfig
StorageModule.stub() Minimal config for testing

Key Features

  • S3 — Multi-part upload, server-side encryption, lifecycle rules
  • GCS — Resumable uploads, CMEK, uniform bucket-level access
  • Azure — Block blobs, shared access signatures (SAS), CDN integration
  • R2 — Cloudflare R2 (S3-compatible) support
  • Local driver — On-disk storage for development and CI
  • Memory driver — In-process storage for unit tests
  • Signed URLs — Time-limited GET / PUT pre-signed URLs for direct browser upload
  • Content negotiation — Automatic MIME type detection from extension and magic bytes
  • Key-value storeInMemoryKVStorage (memory) / LocalStorage (file) for small blobs (config, flags)
  • Streamingstream() yields chunks for arbitrarily large files

Testing

async with Application.boot(modules=[StorageModule.stub()]) as app:
    # your test code
    ...

Key Source Files

File What it contains
src/lexigram/storage/module.py StorageModule class with factory methods
src/lexigram/storage/di/provider.py StorageProvider — wires storage protocols into DI container
src/lexigram/storage/config.py StorageConfig and sub-config classes
src/lexigram/storage/backends/ Driver implementations (AbstractDriver, S3, GCS, Azure, R2, local, memory)
src/lexigram/storage/kv/ KV backends (InMemoryKVStorage, LocalStorage)

Download files

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

Source Distribution

lexigram_storage-0.1.5004.tar.gz (89.0 kB view details)

Uploaded Source

Built Distribution

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

lexigram_storage-0.1.5004-py3-none-any.whl (66.8 kB view details)

Uploaded Python 3

File details

Details for the file lexigram_storage-0.1.5004.tar.gz.

File metadata

  • Download URL: lexigram_storage-0.1.5004.tar.gz
  • Upload date:
  • Size: 89.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.14

File hashes

Hashes for lexigram_storage-0.1.5004.tar.gz
Algorithm Hash digest
SHA256 bfe7850398f6535a128beb824ecba154e78ad19c35a3902c4cd88a0b33c815cd
MD5 2e127c27146740b3c03f006123d6381c
BLAKE2b-256 167b3668fdd99c4367d2ce642c2735f0e5ef5ba6b2c870709ccbab006eded6a1

See more details on using hashes here.

File details

Details for the file lexigram_storage-0.1.5004-py3-none-any.whl.

File metadata

File hashes

Hashes for lexigram_storage-0.1.5004-py3-none-any.whl
Algorithm Hash digest
SHA256 a28ee2de28155fbbdac11bc603a742812a2dd3d35945dd04fbdca0d9bfcdd22e
MD5 83d3428f52df09186c647bba36ca0cde
BLAKE2b-256 2e0a1a6ad711bea8ecc99fd360a5313492e7d8e639f1663b0d324d6dfb7d44ce

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.5009

1 file

This release

0.1.5004 This release

2 files

0.1.5001

2 files

0.1.3007

1 file

0.1.3006

1 file

0.1.3005

1 file

0.1.4

2 files

0.1.2

1 file

0.1.0

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