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

Install optional extras based on what you need:

pip install 'fastapi-storages[s3]'
pip install 'fastapi-storages[sqlalchemy]'
pip install 'fastapi-storages[peewee]'
pip install 'fastapi-storages[image]'
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.5.0.tar.gz (7.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.5.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastapi_storages-0.5.0.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","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.5.0.tar.gz
Algorithm Hash digest
SHA256 558c030daca6992c96ea3811648a1afa165dbdd13635d2b6e196d39556951afc
MD5 53418bc87f04258552c215d7c9b278a6
BLAKE2b-256 ce45d5920a64fdcc014b69e8db0a74d419f00d5998fdcbf5b92a8c5ada224649

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fastapi_storages-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","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.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 82c487c04019ea822b259842280e5f1c5d536a193a7090ce3c271078063a919c
MD5 5310fcb885cf552cb0311f7dfc2e9760
BLAKE2b-256 89d9c12fc71b82d5bc47e53aab6776eb34798e1fc263ff7b9049c510bbe6d5c3

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