zaris/stable/: fastapi-storages-0.3.0 metadata and description

Simple index PyPI page

FastAPI Storages

author_email Amin Alaee <me@aminalaee.dev>
classifiers
  • Development Status :: 4 - Beta
  • Programming Language :: Python
  • Programming Language :: Python :: 3.8
  • Programming Language :: Python :: 3.9
  • Programming Language :: Python :: 3.10
  • Programming Language :: Python :: 3.11
  • Programming Language :: Python :: 3.12
  • Topic :: Database
  • Topic :: Database :: Database Engines/Servers
  • Topic :: Internet
  • Topic :: Internet :: WWW/HTTP
  • Topic :: Internet :: WWW/HTTP :: HTTP Servers
  • Typing :: Typed
description_content_type text/markdown
keywords django,fastapi,orm,sqlalchemy
license_expression MIT
license_file
  • LICENSE.txt
project_urls
  • Documentation, https://github.com/aminalaee/fastapi-storages#readme
  • Issues, https://github.com/aminalaee/fastapi-storages/issues
  • Source, https://github.com/aminalaee/fastapi-storages
provides_extras
  • full
requires_dist
  • boto3~=1.25
  • peewee>=3; extra == 'full'
  • pillow>=10; extra == 'full'
  • sqlalchemy>=1.4; extra == 'full'
requires_python >=3.8
File Tox results History
fastapi_storages-0.3.0-py3-none-any.whl
Size
10 KB
Type
Python Wheel
Python
3

Build Status Publish Status Coverage Package version Supported Python versions


FastAPI Storages

A collection of backend storages and ORM extensions to simplify file management in FastAPI and Starlette projects.

Similar to django-storages project, but aiming to work with a wider range of database ORMs and backends.


Documentation: https://aminalaee.dev/fastapi-storages

Source Code: https://github.com/aminalaee/fastapi-storages


Installation

pip install fastapi-storages
pip install 'fastapi-storages[full]'

Supported integrations

Supported storage backends

Example

from fastapi import FastAPI, UploadFile
from sqlalchemy import Column, Integer, create_engine
from sqlalchemy.orm import Session, declarative_base
from fastapi_storages import FileSystemStorage
from fastapi_storages.integrations.sqlalchemy import FileType

app = FastAPI()
Base = declarative_base()
engine = create_engine("sqlite:///test.db")


class Example(Base):
    __tablename__ = "example"

    id = Column(Integer, primary_key=True)
    file = Column(FileType(storage=FileSystemStorage(path="/tmp")))


# Create database and table
Base.metadata.create_all(engine)


@app.post("/upload/")
def create_upload_file(file: UploadFile):
    example = Example(file=file)
    with Session(engine) as session:
        session.add(example)
        session.commit()
        return {"filename": example.file.name}