neversight/learn-skills.dev/litestar-file-uploads
Claude Code and agent skill by neversight/learn-skills.dev
- community
Checking that the SKILL.md file is still in the repository.
Handle Litestar multipart file uploads securely with `UploadFile`, typed multipart models, multi-file inputs, request body limits, and storage-safe processing patterns. Use when accepting single or multiple uploaded files in request bodies, especially multipart form-data endpoints. Do not use for generic request parsing, static asset serving, or download response behavior.
Install
npx vskill@latest install neversight/learn-skills.dev/litestar-file-uploadsSKILL.md
The same SKILL.md was published earlier as neversight/learn-skills.dev/litestar-file-uploads.
File Uploads
Execution Workflow
- Decide whether the endpoint truly needs multipart file transport.
- Choose the input shape: single
UploadFile, typed multipart model,dict[str, UploadFile], orlist[UploadFile]. - Declare multipart explicitly with
Body(media_type=RequestEncodingType.MULTI_PART). - Validate filename, content type, size expectations, and field layout before expensive processing.
- Stream or hand off large files to storage/services without unbounded memory use.
- Keep upload parsing and validation at the transport edge; move persistence and scanning into services.
Core Rules
- Treat every uploaded file as untrusted input.
- Type uploads explicitly with
UploadFileor multipart container models. - Prefer typed multipart models when field names and structure are known.
- Use
dict[str, UploadFile]orlist[UploadFile]only when the field layout is dynamic or intentionally loose. - Keep request size limits explicit with
request_max_body_sizewhen defaults are not sufficient. - Avoid reading whole files into memory unless the endpoint contract is small and bounded.
- Keep upload endpoints aligned with
litestar-requestsfor broader request-parsing concerns.
Decision Guide
- Use a single
UploadFilewhen one file is the entire body contract. - Use a typed dataclass or model when multipart mixes files and ordinary fields.
- Use
dict[str, UploadFile]when filenames/field names are dynamic and validation is minimal. - Use
list[UploadFile]when the files are homogeneous and field names do not matter. - Use async file reads in async handlers and direct
data.file.read()in sync handlers. - Lower
request_max_body_sizefor sensitive upload endpoints unless a larger bound is justified.
Reference Files
Read only the sections you need:
- For single-file uploads, typed multipart models, multi-file forms, and async vs sync upload handling, read references/upload-patterns.md.
- For request body limits,
UploadFileinternals, safe processing guidance, and test patterns, read references/limits-and-testing.md.
Recommended Defaults
- Prefer multipart models when the field layout is fixed.
- Keep upload endpoints narrow and purpose-built.
- Validate metadata before scanning, persisting, or transforming the file.
- Leave the global body-size limit in place unless a route has a documented reason to override it.
- Return only minimal safe metadata to clients after upload.
Anti-Patterns
- Using multipart uploads when plain JSON or form data would do.
- Accepting unbounded file bodies without a front-door size limit.
- Reading large files fully into memory by default.
- Returning internal temp-file paths or unsafe metadata to clients.
- Mixing storage, scanning, and persistence logic directly into the route handler.
- Treating
dict[str, UploadFile]as the default when the form shape is actually known.
Validation Checklist
- Confirm multipart media type is declared explicitly.
- Confirm the chosen upload shape matches the real form contract.
- Confirm body-size limits are appropriate for the endpoint.
- Confirm async vs sync file access matches the handler style.
- Confirm large uploads do not exhaust memory unexpectedly.
- Confirm invalid or unexpected files fail with deterministic client errors.
- Confirm upload metadata returned to clients is minimal and safe.
Cross-Skill Handoffs
- Use
litestar-requestsfor non-file request parsing and mixed request contract design. - Use
litestar-responsesfor download and file-serving behavior after upload. - Use
litestar-testingfor multipart and size-limit regression coverage. - Use
litestar-securitywhen upload endpoints need auth, secret transport, or strict policy enforcement.
Litestar References
- https://docs.litestar.dev/latest/usage/requests.html#file-uploads
- https://docs.litestar.dev/latest/usage/requests.html
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingdata/skills-md/alti3/litestar-skills/litestar-file-uploads/SKILL.md
Popularity
- Repository stars
- 218
- Repository forks
- 38
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/neversight/learn-skills.dev/litestar-file-uploads)