Skip to main content

A plug-and-play file management package for FastAPI.

Project description

File Manager for FastAPI

A plug-and-play solution for managing file uploads in FastAPI apps. It handles file uploads, saves them uniquely, and serves them via a static route automatically.

Installation

Install using pip:

pip install fastapiFileManager


#File manager for fastApi is designed to be a plug and play package to manage files in fastapi just like in django. you only need three line of code:

from fastapiFileManager import FileManager
file_manager = FileManager(app=app, base_path="uploads", route_path="/
files")

    file_url = file_manager.save_file(file)


## full example:



from fastapi import FastAPI, UploadFile
from file_manager import FileManager

app = FastAPI()

# Initialize FileManager
file_manager = FileManager(app=app, base_path="uploads", route_path="/files")

 
@app.post("/upload")
async def upload_file(file: UploadFile):
    # Save the file and get its URL
    file_url = file_manager.save_file(file)
    return {"file_url": file_url, "check as": f"localhost:8000/{file_url}"}


@app.get("/download/{filename}")
async def download_file(filename: str):
    # Serve the file for download
    return file_manager.serve_file(filename)



# file-manager

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

fastapifilemanager-1.1.0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

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

fastapiFileManager-1.1.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file fastapifilemanager-1.1.0.tar.gz.

File metadata

  • Download URL: fastapifilemanager-1.1.0.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for fastapifilemanager-1.1.0.tar.gz
Algorithm Hash digest
SHA256 09c9fc38ff9b4787469ef24f3478589ceec5b8e6bbdd2ddfa5799bfd0e9e46e2
MD5 4b79d141f08259eb0cbd912199b7c74b
BLAKE2b-256 22f480732973343980625fb557c02df9b0cacb5f473af832a90d009d116952a2

See more details on using hashes here.

File details

Details for the file fastapiFileManager-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapiFileManager-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1916f8052f8aa94882e533487790a51a04803bdda8c021721a1e5a937cbf02ed
MD5 16ec40473280722d2aaf0c4089aac2b6
BLAKE2b-256 6f15295249a4a10456b293dc5f9b85b2c3b56974063845a59beaca28378e6ab3

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