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: e5e25d2fd9/README.md (formidable--incomingform)
This commit is contained in:
parent
0f7d648975
commit
b7d3f3519e
1 changed files with 4 additions and 2 deletions
|
|
@ -26,8 +26,10 @@ export default async function handler(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a formidable instance to parse the request as a multipart form
|
// Create a formidable instance to parse the request as a multipart form
|
||||||
const form = new formidable.IncomingForm();
|
const options = {
|
||||||
form.maxFileSize = 30 * 1024 * 1024; // Set the max file size to 30MB
|
maxFileSize: 30 * 1024 * 1024 // Set the max file size to 30MB
|
||||||
|
};
|
||||||
|
const form = formidable(options);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { fields, files } = await new Promise<{
|
const { fields, files } = await new Promise<{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue