Formidable Nodejs là gì
Show formidable
If you have any how-to kind of questions, please read the Contributing Guide and Code of Conduct documents. This project is semantically versioned and available as part of the Tidelift Subscription for professional grade assurances, enhanced support and security. Learn more. The maintainers of formidable and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the Open Source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Project Status: MaintainedCheck VERSION NOTES for more information on v1, v2, and v3 plans, NPM dist-tags and branches. This module was initially developed by @felixge for Transloadit, a service focused on uploading and encoding images and videos. It has been battle-tested against hundreds of GBs of file uploads from a large variety of clients and is considered production-ready and is used in production for years. Currently, we are few maintainers trying to deal with it. :) More contributors are always welcome!️Jump on issue #412 which is closed, but if you are interested we can discuss it and add you after strict rules, like enabling Two-Factor Auth in your npm and GitHub accounts. Highlights
InstallThis project requires Node.js >= 10.13. Install it using yarn or npm. This is a low-level package, and if you're using a high-level framework it may already be included. Check the examples below and the examples/ folder. # v2
npm install formidable
npm install formidable@latest
npm install formidable@v2
# or v3
npm install formidable@v3 Note: In near future v3 will be published on the latest NPM dist-tag. Future not ready releases will continue to be published on canary dist-tag. ExamplesFor more examples look at the examples/ directory. with Node.js http moduleParse an incoming file upload, with the Node.js's built-in http module. const http = require('http');
const formidable = require('formidable');
const server = http.createServer((req, res) => {
if (req.url === '/api/upload' && req.method.toLowerCase() === 'post') {
// parse a file upload
const form = formidable({ multiples: true });
form.parse(req, (err, fields, files) => {
if (err) {
res.writeHead(err.httpCode || 400, { 'Content-Type': 'text/plain' });
res.end(String(err));
return;
}
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ fields, files }, null, 2));
});
return;
}
// show a file upload form
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(`
With Node.js
|
Felix Geisendörfer | Charlike Mike Reagent ️ | Kedar ️ | Walle Cyril | Xargs | Amit-A |
Charmander | Dylan Piercey | Adam Dobrawy | amitrohatgi | Jesse Feng | Nathanael Demacon |
MunMunMiao | Gabriel Petrovay | Philip Woods | Dmitry Ivonin | Claudio Poli |
From a Felix blog post:
- Sven Lito for fixing bugs and merging patches
- egirshov for contributing many improvements to the node-formidable multipart parser
- Andrew Kelley for also helping with fixing bugs and making improvements
- Mike Frey for contributing JSON support
License
Formidable is licensed under the MIT License.