Skip to main content

FastAPI Storages

Project description

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

  • SQLAlchemy
  • SQLModel
  • SQLAdmin

Supported storage backends

  • FileSystemStorage
  • S3Storage

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}

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

fastapi_storages-0.2.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

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

fastapi_storages-0.2.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_storages-0.2.0.tar.gz.

File metadata

  • Download URL: fastapi_storages-0.2.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.24.1

File hashes

Hashes for fastapi_storages-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0d6cca05076c30bfbe972f070226f08f06cc6823b84d5144fce76eb8a06d5684
MD5 8a4a9f270e7897e100ce1ad0b3a20370
BLAKE2b-256 0c4b512d5658b62b13e719d87524ac62d9dcf36c471dfef31d5a81b063c5ea2b

See more details on using hashes here.

File details

Details for the file fastapi_storages-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_storages-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 251e72dca4998d2c2c33d4721dd8281e753e539b620d9d80d1e904ba1ff4eb18
MD5 1d75c62add945733a0d15706b8ee0169
BLAKE2b-256 6f47720f8785c94c02b151a45504c9b726014ab3d8d8470449a1b42557371ad0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page