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?
✗ Incorrect
The 'single' method handles one file upload with the specified field name.
How do you specify the folder where Multer saves uploaded files?
✗ Incorrect
The 'destination' option inside diskStorage sets the folder path for saving files.
What property in Multer limits the maximum file size?
✗ Incorrect
The 'fileSize' property inside 'limits' sets the max allowed file size in bytes.
Where does Multer store information about the uploaded file when using 'single'?
✗ Incorrect
For single file uploads, Multer adds the file info to req.file.
What does the 'fileFilter' function receive as arguments?
✗ Incorrect
'fileFilter' receives the request, the file object, and a callback to accept or reject the file.
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.