From b7d3f3519eea626c971f27260d1c8d14e5a69305 Mon Sep 17 00:00:00 2001 From: Matthew Jericho Go Sy <69558553+jerichosy@users.noreply.github.com> Date: Tue, 12 Sep 2023 07:09:00 +0800 Subject: [PATCH] Fix File Q&A build error due to removed way of assigning options to the Formidable instance (#372) * Pass maxFileSize attribute when instantiating IncomingForm() Assigning a value through `form.maxFileSize` directly no longer works and will result in `Type error: Property 'maxFileSize' does not exist on type 'IncomingForm'.` * Refactor Formidable instantiation acdg. to example shown in docs Example usage acdg. to docs: https://github.com/node-formidable/formidable/blob/e5e25d2fd9a018c14d7f0014f0a9b8493892b68b/README.md#formidable--incomingform --- apps/file-q-and-a/nextjs/src/pages/api/process-file.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/file-q-and-a/nextjs/src/pages/api/process-file.ts b/apps/file-q-and-a/nextjs/src/pages/api/process-file.ts index 2d874d5..2b0d228 100644 --- a/apps/file-q-and-a/nextjs/src/pages/api/process-file.ts +++ b/apps/file-q-and-a/nextjs/src/pages/api/process-file.ts @@ -26,8 +26,10 @@ export default async function handler( } // Create a formidable instance to parse the request as a multipart form - const form = new formidable.IncomingForm(); - form.maxFileSize = 30 * 1024 * 1024; // Set the max file size to 30MB + const options = { + maxFileSize: 30 * 1024 * 1024 // Set the max file size to 30MB + }; + const form = formidable(options); try { const { fields, files } = await new Promise<{