Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Can't parse request with big file #816

Closed
majorb22 opened this issue Jan 16, 2022 · 3 comments
Closed

Can't parse request with big file #816

majorb22 opened this issue Jan 16, 2022 · 3 comments

Comments

@majorb22
Copy link

majorb22 commented Jan 16, 2022

Support plan

  • Which support plan is this issue covered by? (Community, Sponsor, Enterprise): Community
  • Currently blocking your project/work? (yes/no): Yes
  • Affecting a production system? (yes/no): No

Context

  • Node.js version: v16.13.0
  • Release Line of Formidable (Legacy, Current, Next): Current
  • Formidable exact version: 2.0.1
  • Environment (node, browser, native, OS): NextJS, macOS BigSur
  • Used with (popular names of modules):

What are you trying to achieve or the steps to reproduce?

When I try to upload files from postman, the query can't be parsed, if I upload big files in it.
I use the same function, don't change it, but if I attach a big file the parse callback function doesn't run, it logs nothing. The file is created in the uploads map, but nothing else happens.

import formidable from 'formidable';

export const config = {
	api: {
		bodyParser: false,
	},
};

export default function handler(req, res) {
	const options = {
		uploadDir: './uploads',
		keepExtensions: true
	}

	const form = formidable(options);

	form.parse(req, (err, fields, files) => {
		console.log('fields:', fields);
		console.log('files:', files);
	});

	res.status(200).json({ name: 'John Doe' })
}

What was the result you got?

Nothing was logged.

What result did you expect?

To log the files

@majorb22 majorb22 added the bug label Jan 16, 2022
@GrosSacASac
Copy link
Contributor

res.status(200).json({ name: 'John Doe' }) should be inside the form.parse callback

@GrosSacASac
Copy link
Contributor

Also you should have at least an if statement to see if there is an error in the form.parse callback see the examples
https://github.com/node-formidable/formidable/blob/master/examples/with-express.js#L21

@majorb22
Copy link
Author

Thank you!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants