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. https://github.com/emeraldlinks/fastapiFileManager

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

fastapifilemanager-1.1.2.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.2-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastapifilemanager-1.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 0f4847f80bd1cbfb29108fd63c550f7ed3a137269a7eafdd96ee8e5175fd4748
MD5 4a6fb1acec356666cd21299a6a0d26bb
BLAKE2b-256 ad6a303918686f86bcacac9128d1d84ceeb541369cd80406cfc7e7a639f58a83

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastapiFileManager-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9847257375fa76eff4c81840060c4a634e4ff8d8a879504193185625a3c90f00
MD5 e3c1aea2271aaeef0193e2a603253930
BLAKE2b-256 946a1dfa455f6ac045e589de4f274bf4227dbdc0f942d0eb0f0c0a2fc10b1c99

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