Node.js Multer Middleware Not Handling File Uploads with Large Files Properly
Hey everyone, I'm running into an issue that's driving me crazy. I'm working on a personal project and I'm using Node.js with Express and the `multer` middleware to handle file uploads. However, when I try to upload a large file (around 50MB), I encounter the behavior `behavior: ENOENT: no such file or directory, open 'uploads/undefined'`. I understand that `multer` saves the files to a specified destination, but it seems to be failing to set the destination correctly for large files. Here's the relevant part of my code: ```javascript const express = require('express'); const multer = require('multer'); const app = express(); const storage = multer.diskStorage({ destination: function (req, file, cb) { cb(null, 'uploads/') }, filename: function (req, file, cb) { cb(null, file.originalname); } }); const upload = multer({ storage: storage }); app.post('/upload', upload.single('file'), (req, res) => { res.send('File uploaded successfully!'); }); app.listen(3000, () => { console.log('Server is running on port 3000'); }); ``` I've tried increasing the `limits` in my `multer` configuration, but the behavior continues: ```javascript const upload = multer({ storage: storage, limits: { fileSize: 100 * 1024 * 1024 } // 100MB limit }); ``` I also checked the destination folder permissions and they are set correctly. When I upload smaller files (less than 10MB), everything works fine, but I need to seem to figure out what's going wrong with larger files. Is there something I'm missing, or is there a specific handling needed for larger uploads in `multer`? Any insights would be greatly appreciated! What's the best practice here?