aj-geddes avatar

File Upload Handling

This handles the full lifecycle of file uploads: validation, sanitization, virus scanning, storage, and serving. You get reference implementations for Flask, FastAPI, and Express with Multer, plus S3 integration patterns. The examples cover the security essentials like MIME type validation, secure filename generation, and directory traversal prevention. Most useful when you're building upload features from scratch and want to avoid the common security pitfalls. The emphasis on signed URLs and CDN integration shows it's thinking beyond just accepting files. Solid starting point if you need more than a basic multipart form handler.

skills.sh installs
483
GitHub stars
379
last updated
Aug 21, 2026

Install

$ npx -y skills add aj-geddes/useful-ai-prompts --skill file-upload-handling --agent claude-code

Installs into .claude/skills of the current project.

Files

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

Sponsors

Details

Repository
github.com/aj-geddes/useful-ai-prompts
Category
AI & Agent Building
First seen
Jun 3, 2026

More from aj-geddes/useful-ai-prompts

All 258
1pspdfkit-labs avatarnutrient-document-processingpspdfkit-labs/nutrient-agent-skillProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble or split packets, OCR scan483skills.sh installs
2webmaxru avatarenonic-guillotine-query-builderwebmaxru/enonic-agent-skillsComposes, debugs, and optimizes Guillotine GraphQL queries for Enonic XP headless content delivery. Covers query construction, variable usage, filtering, aggreg483skills.sh installs
3aj-geddes avatarxss-preventionaj-geddes/useful-ai-promptsPrevent Cross-Site Scripting (XSS) attacks through input sanitization, output encoding, and Content Security Policy. Use when handling user-generated content in482skills.sh installs
4auth0 avatarauth0-androidauth0/agent-skillsUse when adding Auth0 login, logout, or credential management to an Android app in Kotlin or Java. Covers Web Auth, biometric-protected CredentialsManager, and 482skills.sh installs
5aj-geddes avatardependency-managementaj-geddes/useful-ai-promptsManage project dependencies across languages including npm install, package versioning, dependency conflicts, security scanning, and lock files. Use when dealin481skills.sh installs
6aj-geddes avatarcircuit-breaker-patternaj-geddes/useful-ai-promptsImplement circuit breaker patterns for fault tolerance, automatic failure detection, and fallback mechanisms. Use when calling external services, handling casca480skills.sh installs