Every Node.js backend eventually needs a file upload endpoint. And every time, the same questions come back:
How do I stop someone from uploading a 5 GB file, or 10,000 tiny ones?
How do I make sure ../../etc/passwd never ends up as a filename on my disk?
Why does moving from local disk to S3 (or Azure) mean rewriting my routes?
Why does my "simple upload" pull in a tree of transitive dependencies?
I built @xkid1/multipart to answer those once. It's a multipart/form-data parser written in TypeScript with zero runtime dependencies , Express and NestJS middleware, and storage adapters for the local filesystem, AWS S3 and Azure Blob Storage, all behind one interface.
This post walks through how it works and how to use it.
Install
npm install @xkid1/multipart
Enter fullscreen mode
Exit fullscreen mode
You only install the SDKs for the pieces you use:
You use Also install
Core parser / local nothing
Express express
NestJS @nestjs/common reflect-metadata rxjs
AWS S3 @aws-sdk/client-s3
Azure Blob…