Complete the code to set the file size limit to 1MB using express.json().
app.use(express.json({ limit: '[1]' }));The correct way to specify 1 megabyte is '1mb' which equals 1MB in express.json() limit option.
Complete the code to limit file uploads to 5MB using multer.
const upload = multer({ limits: { fileSize: [1] } });Multer expects fileSize limit in bytes. 5MB equals 5242880 bytes (5 * 1024 * 1024).
Fix the error in setting the file size limit for express.urlencoded().
app.use(express.urlencoded({ extended: true, limit: '[1]' }));The limit option expects a string with size and unit, '1024kb' correctly sets 1MB limit.
Fill both blanks to set multer to accept files up to 2MB and only single file named 'avatar'.
const upload = multer({ limits: { fileSize: [1] } });
app.post('/profile', upload.[2]('avatar'), (req, res) => { res.send('Uploaded'); });File size limit is 2MB in bytes (2097152). To accept one file named 'avatar', use upload.single('avatar').
Fill all three blanks to create an express.json() middleware with 10MB limit, and multer to accept multiple files named 'photos' with 3 files max.
app.use(express.json({ limit: '[1]' }));
const upload = multer({ limits: { fileSize: [2] } });
app.post('/upload', upload.[3]('photos', 3), (req, res) => { res.send('Files uploaded'); });express.json() limit is '10mb' string. Multer fileSize limit is 10MB in bytes (10485760). To accept multiple files named 'photos' max 3, use upload.array('photos', 3).