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 fastapiFileManager 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastapifilemanager-1.1.1.tar.gz.
File metadata
- Download URL: fastapifilemanager-1.1.1.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bacd0121c760cead2fdcd1aea09e14a5d35c3d5d6f2467713477c4357a4c2a4a
|
|
| MD5 |
7454e54932df9c736ddbe41a313f17dd
|
|
| BLAKE2b-256 |
155a3287de26d33fe6c612d68765b4770532ea4323c4760c9d64371c566f2dd3
|
File details
Details for the file fastapiFileManager-1.1.1-py3-none-any.whl.
File metadata
- Download URL: fastapiFileManager-1.1.1-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a726270c76614a7ab1581aff06fbe408b26e728f61373024802abce85f70a510
|
|
| MD5 |
0a81543f90db65feef44c8c1e1553586
|
|
| BLAKE2b-256 |
e8aed1a8a0694afa57aecfddf5e1124b368438bac50568a644ac0f36266c489b
|