Skip to main content

A simple file manager for FastAPI with cloud support

Project description

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. It also supports cloud storage solutions like Cloudinary, AWS S3, Firebase, and Google Cloud Storage. GitHub Repository

Installation Install using pip:

bash Copy Edit pip install fastapiFileManager Quick Start fastapiFileManager is designed to be a plug-and-play package to manage files in FastAPI, just like in Django. You only need three lines of code to get started:

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

file_url = file_manager.save_file(file) Full Example: python Copy Edit from fastapi import FastAPI, UploadFile from fastapiFileManager import FileManager

app = FastAPI()

Initialize FileManager (can be configured to use Cloud services)

file_manager = FileManager( app=app, cloud="cloudinary", # Options: 'local', 'cloudinary', 'aws', 'firebase', 'gcloud' base_path="uploads", # Only used for local storage route_path="/files", cloud_config={ "cloud_name": "your_cloudinary_name", "api_key": "your_api_key", "api_secret": "your_api_secret", # Additional cloud config options for AWS, Firebase, GCloud, etc. } )

@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) Features: Plug-and-play solution: Just integrate and start managing files.

Automatic file serving: Files are served via a static route (for local storage).

Cloud storage support: Supports file uploads to Cloudinary, AWS S3, Firebase, and Google Cloud Storage.

Simple API: Easy to use methods to upload, save, and serve files.

Customizable paths: Specify the base path for saving and the route for serving files.

Cloud Storage Support Cloudinary: A popular cloud service for media management.

AWS S3: Upload files directly to AWS S3 buckets.

Firebase: Upload files to Firebase Storage and make them publicly accessible.

Google Cloud Storage: Upload files to Google Cloud Storage and manage them with public URLs.

Configuration Cloud Option: In the FileManager constructor, you can choose your cloud provider with the cloud argument. The options are:

'local': Use the local filesystem (default).

'cloudinary': Use Cloudinary for storing files.

'aws': Use Amazon S3 for storing files.

'firebase': Use Firebase Storage for storing files.

'gcloud': Use Google Cloud Storage for storing files.

Cloud Config: You can pass a dictionary containing the necessary configuration for your cloud provider in the cloud_config argument:

For Cloudinary, provide cloud_name, api_key, and api_secret.

For AWS S3, provide aws_access_key_id, aws_secret_access_key, and bucket.

For Firebase, provide the firebase_credentials path and firebase_bucket.

For Google Cloud Storage, provide gcloud_credentials and bucket.

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.4.tar.gz (4.4 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.4-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for fastapifilemanager-1.1.4.tar.gz
Algorithm Hash digest
SHA256 86de1e2f28667e090b0392445c176c87d183bdbb257c65edaab57bd49eb2e597
MD5 ce41a413769468ab9cb744bed6259cd4
BLAKE2b-256 743b20a88c5434680c936520e138473bbafaea9f9bcc6993ab9554ce77d03ad7

See more details on using hashes here.

File details

Details for the file fastapifilemanager-1.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapifilemanager-1.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 976ce38ef03fa20828b01589b1fb0958cc93e4f97128dc53046bf14792815921
MD5 104d841febd118c0d813a846114c52d2
BLAKE2b-256 05902ada06bd97ac43e96b2b4fdd70c84a6207d2b96ca5f71af7923b52479bd7

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