Description
Course video uploads currently validate only the filename extension.
A file renamed to .mp4 may pass the current validation even when its MIME type is invalid. There is also no configured upload-size limit, allowing unexpectedly large files to consume server storage or memory.
Proposed solution
Strengthen the Multer configuration by:
- Checking both file extension and MIME type.
- Allowing only expected MP4 MIME types.
- Adding a configurable maximum video size.
- Providing a safe default, such as 250 MB.
- Returning clear
400 or 413 responses for rejected uploads.
- Limiting the maximum number of uploaded section videos.
- Removing already-written files when course creation fails.
- Sanitizing generated filenames.
- Adding tests for accepted and rejected uploads.
Suggested environment setting:
Acceptance criteria
Suggested files
backend/routers/userRoutes.js
backend/controllers/userControllers.js
backend/utils/uploadCleanup.js
backend/.env.example
backend/tests/video-upload.test.js
Description
Course video uploads currently validate only the filename extension.
A file renamed to
.mp4may pass the current validation even when its MIME type is invalid. There is also no configured upload-size limit, allowing unexpectedly large files to consume server storage or memory.Proposed solution
Strengthen the Multer configuration by:
400or413responses for rejected uploads.Suggested environment setting:
Acceptance criteria
Suggested files