Skip to main content

nextjs-api-file-upload

For Next.js App Router, use request.formData() and stream/parse the file (e.g. CSV) in the route handler. Do not use Express-style middleware (e.g. multer) in API routes—it can block the request pipeline and cause hangs. Use when implementing file upload in Next.js API routes.

来源信息

仓库
pmarashian/cursor-agent-skills
最近来源活动
2026年2月13日 19:51
检测到的 SKILL.md 语言
英语
星标
2
分支
1

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
nextjs-api-file-upload
description
For Next.js App Router, use request.formData() and stream/parse the file (e.g. CSV) in the route handler. Do not use Express-style middleware (e.g. multer) in API routes—it can block the request pipeline and cause hangs. Use when implementing file upload in Next.js API routes.
# Next.js API File Upload (App Router) This project uses **Next.js App Router**. File upload in API routes must use Next.js built-in handling, not Express middleware. ## Do Not Use - **Express middleware** (e.g. multer) in API routes. It can block the request pipeline and cause long hangs (e.g. login or upload appearing stuck). ## Do Use - **`request.formData()`** in the route handler. - **Stream or parse the file** (e.g. CSV) inside the handler after calling `formData()`. ## Example Pattern ```typescript // In app/api/upload/route.ts (or similar) export async function POST(request: Request) { const formData = await request.formData(); const file = formData.get('file') as File | null; if (!file) return Response.json({ error: 'No file' }, { status: 400 }); // Parse/stream file in handler (e.g. CSV parsing) // ... } ``` ## Integration - Can be merged into a broader "Next.js API" skill if one exists. Use for any task that adds or changes file upload in Next.js App Router API routes.
在 GitHub 查看