Skip to content

feat: added 50MB file size limit to frontend and backend - #209

Open
PrinceK-Git wants to merge 1 commit into
devfrom
file_upload
Open

PrinceK-Git wants to merge 1 commit into
devfrom
file_upload

Conversation

@PrinceK-Git

Copy link
Copy Markdown
Contributor
Screenshot 2026-10-02 022459 Screenshot 2026-10-02 022344 Screenshot 2026-10-02 022257

Description: This PR introduces a strict 50MB file size limit for all file uploads to prevent users from uploading excessively large files. The restriction is enforced on both the client and server sides.

Changes Made:

Frontend (client/src/screens/contributions/index.jsx):

  1. Integrated filepond-plugin-file-validate-size to enforce the limit before the file leaves the browser.
  2. Added maxFileSize="50MB" to the FilePond component.
  3. Updated labelIdle to display the (Max file size: 50MB) instruction in the idle state so users are aware of the limit beforehand.
  4. Configured specific error messages (labelMaxFileSizeExceeded, labelMaxFileSize) for a clean UI rejection if the limit is exceeded.

Backend (server/modules/contribution/contribution.routes.js):

  1. Added limits: { fileSize: 50 * 1024 * 1024 } to the Multer configuration.
  2. This acts as a fallback security measure to ensure the server automatically rejects oversized payloads even if the frontend validation is bypassed .

@PrinceK-Git PrinceK-Git linked an issue Oct 1, 2026 that may be closed by this pull request
@aditya-samal

aditya-samal commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Please do proper testing of all the possible cases properly before making a PR. I have attached an example of a case:

Screen.Recording.2026-10-02.at.9.47.52.AM.mov

Here either don't allow the user to click submit untill the pond is free of wrong files, or fix the pond to upload only the correct files and ignore the wrong files and close automatically. Currently in this case the user has to refresh the page to upload again.

According to me we should not allow the user to click submit untill pond is clear. If we handle it using the second approach then it might be possible that the user is uploading multiple files but a file which is below the correct files is faulty, and our pond just uploads the correct ones and ignores the wrong one. The user would think that all the files got uploaded successfully. But it is not true.

Enhancements:

  • If the user has to view all the files he has uploaded and find the faulty one, he'll have to scroll in the current pond which is very small. I would suggest revisiting the UI of the current pond, remove unnecessary things from it. Increase the height of the pond so that it gives the user an option view the correct/incorrect files in a better manner.
  • If possible show a small status bar on top right corner showing how many files were valid out of the total number of files uploaded before the user clicks submit.

@aditya-samal

aditya-samal commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Also, you have removed the extra note which you had added and is visible in the screenshots: "Files require approval from BR....". Please keep it. Don't put it as a separate note, you can make it like:
Note:
->Note 1
->Note 2

import multer from "multer";

export const upload = multer({ dest: "external/uploads" });
export const upload = multer({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to do this, the nginx layer will not let 50 MB+ size files to reach this point. Adding this would unnecessarily make the process slow and more prone to errors. Let's keep it simple. If in future we decide to modify the limit, we'll have to update in multiple places like in frontend, server, and nginx layer. So it is better to not over complicate things and keep it simple.

@aditya-samal aditya-samal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From next time, please avoid including package-lock.json or any other files in the PR unless they are actually required for the changes being made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error When trying to upload Large Files (80ish MB)

2 participants