Vishal Rathore
Vishal Rathore

Reputation: 113

Nodejs fileupload, multer vs express-fileupload, which to use?

Which library I should use? The only purpose is to upload the files. I want to go with the most optimal library in terms of performance and scalability in terms of large requests. If my project scales up, I will be eventually using CDN services.

Upvotes: 11

Views: 17497

Answers (1)

Ntshembo Hlongwane
Ntshembo Hlongwane

Reputation: 1051

Here are some few things that you have to consider when choosing library in this context.

Firstly Personal belief:

  • All this things perform the same task so it's all upon preference so whatever that you like to work with go for it do not stress yourself about this and that cause all this is opinion based.

But to answer your question: which should you choose?

  • There are 3 libraries that I would recommend that is Multer, Formidable and Busboy

So which to choose between Multer, Formidable and Busboy

1. If you want to store files in memory or disk:

  • Multer is your go to library

2. If you want to store files in disk:

-Formidable is your go libray

3. For high-volume production-grade solution:

  • When you've got a high-volume situation and want the most reliability from your server, the best option is to not store intermediate files on the Node.js server at all. Instead, you want to push the files to a separate file server as soon as you receive them. The file server can be a cloud storage service such as AWS S3 or a database that supports BLOBs.

Base64 or Multipart?

Base64:

  • Base64 is a way to encode binary data into an ASCII character
  • formating the data to radix-64 representation.
  • If the file uploads that your making are large file uploads then I would for sure with confidence say that do not use Base64 because it converts whole data and post it to server.

Multipart:

  • This is faster
  • Multipart is a way to upload data to server in the form of part which are in bytes. Multpart/form-data is applied to a form though, so you can send everything in a multi-part form, including "regular" data also.

Upvotes: 24

Related Questions