Skip to content

Implement multipart/form-data file upload support using busboy#12

Open
Robert0303-C wants to merge 1 commit intobogeeee:mainfrom
Robert0303-C:fix/remove-unused-busboy-dependency
Open

Implement multipart/form-data file upload support using busboy#12
Robert0303-C wants to merge 1 commit intobogeeee:mainfrom
Robert0303-C:fix/remove-unused-busboy-dependency

Conversation

@Robert0303-C
Copy link
Copy Markdown

Summary

This PR implements multipart/form-data file upload support using the busboy library.

Changes

  • Add busboy and @types/busboy as dependencies in server package
  • Implement multipart/form-data parsing with proper security limits:
    • MAX_FILE_SIZE: 100MB per file
    • MAX_FILES: 10 files max
    • MAX_FIELDS: 100 fields max
    • MAX_TOTAL_PARTS: 1000 parts max
    • MAX_HEADER_PAIRS: 2000 header pairs max
  • Make collectParamsFromRequest async to support await for Promise-based parsing
  • Extract fields and files from multipart body and pass to convertAndAddParams
  • Files are stored as UploadFile objects with createReadStream method
  • Handle multiple values for same field name
  • Proper error handling with CommunicationError wrapper

Security

The implementation includes multiple security limits to prevent DoS attacks:

  • File size limits per file
  • Maximum number of files
  • Maximum number of fields
  • Maximum number of total parts
  • Maximum number of header pairs

Notes

  • The previous implementation threw a CommunicationError with message "multipart/form-data file uploads not yet implemented"
  • The UploadFile type follows the existing interface from restfuncs-common with createReadStream

Fixes #6

- Add busboy and @types/busboy as dependencies
- Implement multipart/form-data parsing with proper security limits:
  - MAX_FILE_SIZE: 100MB per file
  - MAX_FILES: 10 files max
  - MAX_FIELDS: 100 fields max
  - MAX_TOTAL_PARTS: 1000 parts max
  - MAX_HEADER_PAIRS: 2000 header pairs max
- Make collectParamsFromRequest async to support await for Promise-based parsing
- Extract fields and files from multipart body and pass to convertAndAddParams
- Files are stored as UploadFile objects with createReadStream method
- Handle multiple values for same field name
- Proper error handling with CommunicationError wrapper
@Robert0303-C
Copy link
Copy Markdown
Author

/claim #6

@opirebot
Copy link
Copy Markdown

opirebot bot commented Mar 31, 2026

👀 We've notified the reward creators here.
Make sure your payment account is ready to receive the payment for your hard work 💪

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.

Supply-chain: Review or rewrite the busboy library.

2 participants