0
0
Expressframework~5 mins

Multer middleware setup in Express - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is Multer in Express?
Multer is a middleware for Express that helps handle file uploads from forms. It processes files sent through HTTP requests and saves them to the server or memory.
Click to reveal answer
beginner
How do you set up Multer to store uploaded files in a folder named 'uploads'?
You create a Multer storage engine using multer.diskStorage() and set the destination to 'uploads'. Then, pass this storage to multer() to create the middleware.
Click to reveal answer
beginner
What does the 'single' method in Multer do?
The 'single' method tells Multer to accept a single file with the given field name from the form. It adds the file info to req.file.
Click to reveal answer
intermediate
How can you limit the file size of uploads using Multer?
You can set the 'limits' option in Multer configuration with a 'fileSize' property in bytes to restrict the maximum upload size.
Click to reveal answer
intermediate
What is the purpose of the 'fileFilter' option in Multer?
The 'fileFilter' option lets you control which files are accepted by checking the file type or other properties before saving.
Click to reveal answer
Which Multer method is used to handle a single file upload?
Asingle
Barray
Cfields
Dnone
How do you specify the folder where Multer saves uploaded files?
AUsing the 'limits' option
BUsing the 'fileFilter' option
CUsing the 'destination' option in diskStorage
DUsing the 'single' method
What property in Multer limits the maximum file size?
Astorage
BfileFilter
CmaxFiles
DfileSize in limits
Where does Multer store information about the uploaded file when using 'single'?
Areq.body
Breq.file
Creq.files
Dreq.upload
What does the 'fileFilter' function receive as arguments?
Areq, file, callback
Breq, res, next
Cfile, callback
Dreq, res
Explain how to set up Multer middleware to accept a single file upload and save it to a specific folder.
Think about creating storage, then middleware, then using it in a route.
You got /4 concepts.
    Describe how to control which files Multer accepts and how to limit file size.
    Consider validation and size restrictions in Multer config.
    You got /2 concepts.