node-uploadx is a robust Node.js middleware designed for handling resumable file uploads, supporting protocols like Tus (implicitly, through its resumable features). It abstracts away the complexities of chunked uploads, error recovery, and storage management, making it suitable for applications requiring reliable file transfer. The library, currently at version 6.2.1, maintains a regular release cadence, primarily focusing on bug fixes, security enhancements, and minor feature additions as seen in recent patch versions. Key differentiators include its flexible storage options (local filesystem, S3, GCS), integrated metadata handling, built-in validation for file types and sizes, and extensibility for custom scenarios. It integrates seamlessly with popular Node.js frameworks like Express, providing a server-side backbone for client-side upload libraries such as Uppy or ngx-uploadx.
npm install node-uploadxVerified import paths — ran on the pinned version, not inferred.
This quickstart sets up an Express server with node-uploadx to handle resumable file uploads to a local disk. It demonstrates basic configuration including CORS, a custom upload directory, filename generation, and a completion callback.
Upgrade `node-uploadx` to version `6.1.7` or newer to mitigate the `parse-duration` ReDoS vulnerability.
Upgrade `node-uploadx` to version `6.2.1` or newer to ensure the fix for prototype pollution is applied.
Review the `aws-sdk-js-v3` migration guides and ensure your S3 client configurations (e.g., credentials, region, bucket setup) are compatible with the latest SDK version bundled or required by `@uploadx/s3`.
Ensure `cors()` middleware is placed before `Uploadx.middleware()` in your Express app. Configure `cors({ origin: 'your-client-domain', credentials: true })` appropriately for production. For development, `origin: '*'` may be used but is insecure for production.Convert your consuming file to an ES Module by using `import` statements and ensuring your `package.json` has `"type": "module"` or the file ends with `.mjs`.
Ensure `Uploadx.middleware()` is called with its configuration object to return the actual middleware function. Verify the import statement `import { Uploadx } from 'node-uploadx';` is correct and not trying to import a default export as a named one, or vice-versa.Increase the `maxUploadSize` option in your `Uploadx` configuration, e.g., `maxUploadSize: '5GB'` to allow larger files. Ensure this limit aligns with your server's available resources and security policies.
Install and configure the `cors` middleware in your Express application *before* `Uploadx.middleware`. For development, `app.use(cors({ origin: '*' }))` can be used. For production, specify your client's exact origin, e.g., `app.use(cors({ origin: 'http://your-client-domain.com' }))`.