feat: add filename to LIMIT_FILE_SIZE error#1416
Open
UjjwalKumar239 wants to merge 2 commits into
Open
Conversation
When a file exceeds the size limit, the MulterError now includes a filename property alongside the existing field property. This allows users to identify which specific file was rejected, not just which form field it came from. Closes expressjs#607
When a file exceeds the size limit, the MulterError now includes a filename property alongside the existing field property. This allows users to identify which specific file was rejected, not just which form field it came from. Also fixed hardcoded Unix path separator in test/functionality.js for cross-platform compatibility on Windows. Closes expressjs#607
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #607
When multiple files are uploaded and one exceeds the file size limit,
the MulterError only exposes
err.field(the form field name).This makes it impossible to tell the user which specific file was rejected.
Fix
filenameparameter toMulterErrorconstructorLIMIT_FILE_SIZEtriggers, botherr.field(fieldname)and
err.filename(original filename) are now availableerr.fieldis unchangedTesting
Updated test/error-handling.js to assert
err.filenameis set correctly.72 tests passing.