multiparty is a Node.js library designed for parsing `multipart/form-data` HTTP requests, which are primarily used for handling file uploads. It offers streaming capabilities, allowing developers to process form fields and files incrementally as they are received, a key feature for handling large uploads efficiently without consuming excessive memory. The current stable version, 4.2.3, was last published approximately four years ago, indicating a maintenance-only or inactive development cadence rather than active feature development. The library's own documentation suggests `busboy` as a "faster alternative," highlighting a performance consideration. multiparty provides a straightforward, event-driven API centered around the `multiparty.Form` class, making it a functional choice for applications needing to handle file uploads in a Node.js environment, though users should be aware of its age and the existence of more modern, performance-optimized alternatives.
npm install multipartyVerified import paths — ran on the pinned version, not inferred.
This quickstart sets up a basic Node.js HTTP server to handle `multipart/form-data` uploads using `multiparty`. It demonstrates parsing fields and files, writing files to a temporary directory, and includes important cleanup of those temporary files.
Evaluate alternatives like `busboy` or `multer` for better performance and more active development.
Always use CommonJS `require` syntax: `const multiparty = require('multiparty');`.For each `part` event, ensure `part.resume()` is called (to discard data) or its data is fully consumed (e.g., `part.pipe(destinationStream)`).
Implement robust error handling for `form.on('error', ...)` and configure limits appropriately in the `multiparty.Form` constructor based on expected usage.After successful processing, use `fs.rename()` to move files to a permanent location or `fs.unlink()` to delete them. Ensure error handling for these file operations.
Ensure `multiparty` is required using `const multiparty = require('multiparty');` and `Form` is accessed as a property: `new multiparty.Form()`.Use CommonJS `require` syntax: `const multiparty = require('multiparty');`.For every `part` emitted, ensure its data is read (e.g., `part.on('data', ...)` or `part.pipe(...)`) or explicitly skipped with `part.resume()`.Increase the `maxFieldsSize` or `maxFilesSize` option in the `multiparty.Form` constructor if larger uploads are expected. Example: `new multiparty.Form({ maxFilesSize: 10 * 1024 * 1024 })` for 10MB total files.No dependency data recorded yet.