file-upload-handling▌
aj-geddes/useful-ai-prompts · updated Apr 8, 2026
Build secure and robust file upload systems with validation, sanitization, virus scanning, efficient storage management, CDN integration, and proper file serving mechanisms across different backend frameworks.
File Upload Handling
Table of Contents
Overview
Build secure and robust file upload systems with validation, sanitization, virus scanning, efficient storage management, CDN integration, and proper file serving mechanisms across different backend frameworks.
When to Use
- Implementing file upload features
- Managing user-uploaded documents
- Storing and serving media files
- Implementing profile picture uploads
- Building document management systems
- Handling bulk file imports
Quick Start
Minimal working example:
# config.py
import os
class Config:
MAX_CONTENT_LENGTH = 50 * 1024 * 1024 # 50 MB
UPLOAD_FOLDER = 'uploads'
ALLOWED_EXTENSIONS = {'txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif', 'docx', 'doc'}
UPLOAD_DIRECTORY = os.path.join(os.path.dirname(__file__), UPLOAD_FOLDER)
# file_service.py
import os
import mimetypes
import hashlib
import secrets
from werkzeug.utils import secure_filename
from datetime import datetime
import magic
import aiofiles
class FileUploadService:
def __init__(self, upload_dir, allowed_extensions, max_size=50*1024*1024):
self.upload_dir = upload_dir
self.allowed_extensions = allowed_extensions
self.max_size = max_size
self.mime = magic.Magic(mime=True)
// ... (see reference guides for full implementation)
Reference Guides
Detailed implementations in the references/ directory:
| Guide | Contents |
|---|---|
| Python/Flask File Upload | Python/Flask File Upload |
| Node.js Express File Upload with Multer | Node.js Express File Upload with Multer |
| FastAPI File Upload | FastAPI File Upload |
| S3/Cloud Storage Integration | S3/Cloud Storage Integration |
Best Practices
✅ DO
- Validate file extensions and MIME types
- Check file size before processing
- Use secure filenames to prevent directory traversal
- Store files outside web root
- Implement virus scanning
- Use CDN for file delivery
- Generate signed URLs for direct access
- Log file upload/download events
- Implement access control checks
- Clean up temporary files
❌ DON'T
- Trust user-provided filenames
- Store files in web-accessible directories
- Allow arbitrary file types
- Skip virus scanning for uploaded files
- Expose absolute file paths
- Allow unlimited file sizes
- Ignore access control
- Use predictable file paths
- Store sensitive metadata in filenames
- Forget to validate file content
Discussion
Product Hunt–style comments (not star reviews)- No comments yet — start the thread.
Ratings
4.5★★★★★51 reviews- ★★★★★Ganesh Mohane· Dec 24, 2024
Registry listing for file-upload-handling matched our evaluation — installs cleanly and behaves as described in the markdown.
- ★★★★★Li Ghosh· Dec 20, 2024
file-upload-handling has been reliable in day-to-day use. Documentation quality is above average for community skills.
- ★★★★★Dev Harris· Dec 16, 2024
Keeps context tight: file-upload-handling is the kind of skill you can hand to a new teammate without a long onboarding doc.
- ★★★★★Li Desai· Dec 16, 2024
file-upload-handling fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
- ★★★★★Yash Thakker· Nov 23, 2024
file-upload-handling reduced setup friction for our internal harness; good balance of opinion and flexibility.
- ★★★★★Sakshi Patil· Nov 15, 2024
Keeps context tight: file-upload-handling is the kind of skill you can hand to a new teammate without a long onboarding doc.
- ★★★★★Diya Haddad· Nov 11, 2024
Solid pick for teams standardizing on skills: file-upload-handling is focused, and the summary matches what you get after install.
- ★★★★★Amelia Dixit· Nov 7, 2024
Registry listing for file-upload-handling matched our evaluation — installs cleanly and behaves as described in the markdown.
- ★★★★★Amelia Kapoor· Oct 26, 2024
Useful defaults in file-upload-handling — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
- ★★★★★Dhruvi Jain· Oct 14, 2024
We added file-upload-handling from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.
showing 1-10 of 51