express-formidable2
An Express middleware of Formidable that just works.
Last updated 4 years ago by shailen .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install express-formidable2 
SYNC missed versions from official npm registry.

express-formidable2 Build Status

An Express middleware of Formidable that just works.

What are Express, Formidable, and this?

Express is a fast, unopinionated, minimalist web framework for Node.js.

Formidable is a Node.js module for parsing form data, including multipart/form-data file upload.

So, express-formidable2 is something like a bridge between them, specifically an Express middleware implementation of Formidable.

It aims to just work.

Install

npm install express-formidable2

How to use

const express = require('express');
const formidable = require('express-formidable2');

var app = express();

app.use(formidable());

app.post('/upload', (req, res) => {
  req.fields; // contains non-file fields
  req.files; // contains files
});

And that's it.

express-formidable2 can basically parse form types Formidable can handle, including application/x-www-form-urlencoded, application/json, and multipart/form-data.

Option

app.use(formidable(opts,events));

opts & events are options which can be set to form in Formidable. For example:

app.use(formidable({
  encoding: 'utf-8',
  uploadDir: '/my/dir',
  multiples: true, // req.files to be arrays of files
},[
  {
    type: "progress",
    func: (bytesReceived,bytesExpected) => {
      // write code
    }
  },
  {
    type: "file",
    func: (name,file) => {
      // write code
    }
  }
]);

For the detail, please refer to the Formidable API.

Contribute

git clone https://github.com/noraesae/express-formidable2.git
cd express-formidable2
npm install

To lint and test:

npm test

License

MIT

Current Tags

  • 1.0.3                                ...           latest (4 years ago)

4 Versions

  • 1.0.3                                ...           4 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (6)
Dependents (0)
None

Copyright 2014 - 2021 © npmmirror.com |