Skip to content

Commit e40418f

Browse files
committed
Fix TypeScript unsafe access errors in file upload API
1 parent fbd6251 commit e40418f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/app/api/files/upload/route.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,14 @@ export async function POST(req: Request) {
3939
}
4040

4141
const data = result.data;
42-
const newFile = data.file;
42+
const newFile = data.file as File;
43+
44+
if (!(newFile instanceof File)) {
45+
return NextResponse.json(
46+
{ error: 'Invalid file upload' },
47+
{ status: 400 },
48+
);
49+
}
4350

4451
if (newFile.size === 0) {
4552
return NextResponse.json(

0 commit comments

Comments
 (0)