Thursday, June 08, 2023

node.js file upload packages: Formidable, Busboy, Multer and Multiparty

Choose between Formidable, Busboy, Multer and Multiparty for processing file uploads

Formidable has been around the longest, having released its 1.0 version in 2011. It also has the most weekly downloads on npm. It's not Express.js specific, and it saves files in temporary directory on hard disk.

Busboy is an event-based streaming parser that's not tied to Express.js. Instead of storing intermediate files, it provides a stream to the incoming file. It's been around since 2013. The core multipart/form-data implementation has been extracted to a separate dicer module.

Multer is an Express.js middleware that's been around since 2015. It saves intermediate files either in memory or on hard disk and populates req.files object for consuming the files. You can have fine-grained control over which fields allow files and limit the number of uploaded files. Internally, Multer uses Busboy.

Multiparty is a fork of formidable from around 2013. It has the same functionality as Multiparty, but also allows streaming the files. However, in their documentation, Multiparty recommends using Busboy for a faster alternative.





No comments: