CodexBloom - Programming Q&A Platform

Node.js File Streaming with Multer and AWS S3 - implementing File Size Limits

👀 Views: 60 💬 Answers: 1 📅 Created: 2025-06-12
node.js express aws-s3 multer JavaScript

I'm confused about I'm trying to configure I'm working on a personal project and I'm currently working on a Node.js application using Express and Multer for file uploads, but I'm running into issues when trying to stream large files directly to AWS S3..... My application throws a `PayloadTooLargeError` when files exceeding 5 MB are uploaded, despite my Multer configuration allowing for larger sizes. I've set up Multer like this: ```javascript const multer = require('multer'); const upload = multer({ limits: { fileSize: 100 * 1024 * 1024 } // 100 MB limit }); ``` However, on the server side, when I check the request limits, it seems that the default maximum payload size for Express is still being enforced. I've tried increasing the payload size using: ```javascript app.use(express.json({ limit: '100mb' })); app.use(express.urlencoded({ limit: '100mb', extended: true })); ``` Despite these adjustments, the behavior continues. I’ve also verified that my AWS S3 bucket settings allow for large file uploads. I suspect it might be an scenario with how the middleware is processing the incoming request before it reaches Multer. I'm using Node.js v16.13.0 and Express v4.17.1, and I've followed the standard practices for file uploads. Can anyone guide to troubleshoot this scenario? What am I missing here? My development environment is Windows. Any ideas what could be causing this? Hoping someone can shed some light on this. I recently upgraded to Javascript 3.10.