File upload handling

From rnavarych/alpha-engineer · View interactive version

File upload handling is an AI agent skill from the GitHub repository rnavarych/alpha-engineer. Implement file upload flows with presigned URLs (S3, GCS, R2), multipart/tus resumable uploads, Sharp image processing, drag-and-drop UI with progress indicators, server-side MIME validation via magic bytes, virus scanning, and CDN serving. Use when adding profile pictures, document attachments, med

How to use this skill

Skill file

File Upload Handling

When to use

Core principles

  1. Never trust client-reported types — always validate MIME type server-side by reading magic bytes, not the Content-Type header
  2. Presigned URLs over server proxy — upload directly from client to S3/GCS; never stream file bytes through the application server
  3. Rename to UUIDs — strip original filenames entirely to prevent path traversal, collisions, and enumeration attacks
  4. Process media asynchronously — run Sharp resizing and format conversion in BullMQ jobs, not in the request handler
  5. Clean up orphans — run a periodic job to delete uploads unreferenced in the database; storage costs compound silently

Reference Files

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.