TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Async alternative to Multer and Formidable (Node.js file upload lib)

3 pointsby xarici_ishlerover 2 years ago
Pechkin (the library) was born out of a personal dissatisfaction with Multer: a project at my previous job had complex file upload functionality with fields and lots of files mixed together, and to perform even the most basic validation on the fields, we had to wait until Multer processes &amp; saves all the files, to get access to the req.body. Needless to say, that was painfully slow.<p>As I was trying to rewrite the file upload functionality in Busboy, I realized how events aren&#x27;t a good mental model for `multipart&#x2F;form-data` requests, and async iterators were (IMO) much more suitable for the task.<p>And so, this library was born.<p>API TL;DR:<p>- No temporary files are created, files are not loaded in memory. - No need to provide storage engines, file handlers, event listeners, etc. - The main (and only) function returns a Promise that resolves when all fields are parsed, and the first file is encountered (or the request ended). - The promise contains a populated `fields` object, and a `files` `AsyncIterator&#x2F;AsyncIterable`. - Asynchronously iterate over the files using the `for-await-of` loop or using the `next()` method.<p>I&#x27;d appreciate for any critique and feedback on the API &amp; the documentation :)

no comments

no comments