Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of File Uploads?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/ansh44233-file-uploads)
---
description: Handle file uploads safely: size and type limits, direct-to-storage uploads, malware and path safety, and cleanup
profile: standard
tags: uploads, storage, security, backend
---
# File uploads
Uploads are untrusted input that is also large.
## Limits and validation
- Enforce a max size at the proxy and the app; reject before buffering the whole file.
- Check type by content (magic bytes), not by extension or `Content-Type` alone; allow-list types.
- Generate the stored file name yourself; never use the client name in a filesystem path.
## Architecture
- Prefer direct-to-storage uploads with short-lived presigned URLs; the app only records metadata.
- Serve user files from a separate domain or with `Content-Disposition: attachment` to avoid stored XSS.
- Images: strip EXIF metadata; generate resized variants asynchronously.
## Lifecycle
- Scan with antivirus where the risk warrants it; quarantine until scanned.
- Delete orphaned uploads (abandoned forms) with a lifecycle rule or job.
## Verify
Tests cover an oversized file, a disguised file (e.g. HTML renamed `.png`), and a path-traversal name (`../../x`); all are rejected.