A powerful, extensible, and async-ready cloud object storage backend for FastAPI.
Project description
fastapi-async-storages
A powerful, extensible, and async-ready cloud object storage backend for FastAPI.
Drop-in, plug-and-play cloud storage for your FastAPI apps; with full async support.
Inspired by fastapi-storages, built on modern async patterns using aioboto3.
Features
- Fully asynchronous storage interface designed for FastAPI applications
- Async S3 backend powered by aioboto3
- SQLAlchemy and SQLModel integration
- Typed and extensible design
- Supports FastAPI dependency injection
Installation
uv add fastapi-async-storages
# for s3 support:
uv add "fastapi-async-storages[s3]"
Documentation
Full documentation is available on:
https://fastapi-async-storages.readthedocs.io
Example: FastAPI
from fastapi import FastAPI, UploadFile
from sqlalchemy import Column, Integer
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
from sqlalchemy.orm import sessionmaker, declarative_base
from async_storages import S3Storage
from async_storages.integrations.sqlalchemy import FileType
Base = declarative_base()
app = FastAPI()
storage = S3Storage(...)
engine = create_async_engine("sqlite+aiosqlite:///test.db", echo=True)
# create AsyncSession factory
AsyncSessionLocal = sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
class Example(Base):
__tablename__ = "example"
id = Column(Integer, primary_key=True)
file = Column(FileType(storage=storage))
# create tables inside an async context
@app.on_event("startup")
async def startup():
async with engine.begin() as conn:
await conn.run_sync(Base.metadata.create_all)
@app.post("/upload/")
async def create_upload_file(file: UploadFile):
file_name = f"uploads/{file.filename}"
# upload before commit due to the sqlalchemy binding being sync
await storage.upload(file.file, file_name)
example = Example(file=file)
async with AsyncSessionLocal() as session:
session.add(example)
await session.commit()
return {"filename": example.file.name}
License
Project details
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 fastapi_async_storages-0.1.2.tar.gz.
File metadata
- Download URL: fastapi_async_storages-0.1.2.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fadd603a93c44b7e20ec0d24b2448daae6d6f880450409d89e175bc98c855d04
|
|
| MD5 |
95bdda86db3bed7498bc0f597aca567a
|
|
| BLAKE2b-256 |
c9f014ee008d248f6755eab7e1eef2c2a469e10d39a2fb7f80100e8da5fb2905
|
File details
Details for the file fastapi_async_storages-0.1.2-py3-none-any.whl.
File metadata
- Download URL: fastapi_async_storages-0.1.2-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1928b3d40f6d6592b4e45afdca9efd11e27299ce9a27fdd5d515cb30a488a72
|
|
| MD5 |
297e73859874acac410a3c4842abaee7
|
|
| BLAKE2b-256 |
e8bfc68dcbcb8e39e29b50266a6ce87ac73605d924326731ba064d9a0aa1a039
|