Skip to main content

A simple file manager for FastAPI with optional cloud uploads

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.3.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.3-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastapifilemanager-1.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 a136d69ca421a047b1f41e5f12da36cb993ad243fb2f256d2b3748600c1ccbda
MD5 de07825cc80e26d0f611cbc04f163311
BLAKE2b-256 2d4653e7343698ebad2219c5208c5b8cc58deba26988c8abaad7d6fab94aa1fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastapifilemanager-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d54aa5ed3985f395a8a9c65a3350c04ad6c730d84bdbd182405daddd937636e8
MD5 3041dc4e9206e5a873f24eb4466a773f
BLAKE2b-256 d0585f07132a6ea0548955852909b1fee82a690056b05dd8b9b25c7310212f4f

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