<< All versions
Skill v1.0.1
currentAutomated scan100/100aj-geddes/useful-ai-prompts/file-upload-handling
8 files
──Details
PublishedMay 14, 2026 at 07:49 PM
Content Hashsha256:706d060379fe6643...
Git SHA3f5182cfd739
Bump Typepatch
──Files
Files (1 file, 3.0 KB)
SKILL.md3.0 KBactive
SKILL.md · 104 lines · 3.0 KB
version: "1.0.1" name: file-upload-handling description: > Implement secure file upload handling with validation, virus scanning, storage management, and serving files efficiently. Use when building file upload features, managing file storage, and implementing file download systems.
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:
python
# config.pyimport osclass Config:MAX_CONTENT_LENGTH = 50 * 1024 * 1024 # 50 MBUPLOAD_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.pyimport osimport mimetypesimport hashlibimport secretsfrom werkzeug.utils import secure_filenamefrom datetime import datetimeimport magicimport aiofilesclass FileUploadService:def __init__(self, upload_dir, allowed_extensions, max_size=50*1024*1024):self.upload_dir = upload_dirself.allowed_extensions = allowed_extensionsself.max_size = max_sizeself.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