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://smithyhq.github.io/fastapi-storages

Source Code: https://github.com/smithyhq/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.4.0.tar.gz (6.0 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.4.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastapi_storages-0.4.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","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

Hashes for fastapi_storages-0.4.0.tar.gz
Algorithm Hash digest
SHA256 c66018c310c7a25c9019b22d5a1f044577594ba8825da66d9f76614989995d33
MD5 e6de5bad9a29741cea8a5cf625aa3806
BLAKE2b-256 96cff1f5c38ab7b846b94f4c64206c0865eb0c163170477438d1f3f6341fe2ee

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fastapi_storages-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","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

Hashes for fastapi_storages-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 478a7699aa24f939abdaa577e62a844c77e2d509f5f6a26d4559ca72c9df94f0
MD5 4f7c08a41dd0bf2b7b5203d13e26ace9
BLAKE2b-256 386c1212c106539766e513609a498c39dc09fcaec8f1e48a13a0810d8af6d26e

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