uploadmidnode

0.0.1 • Public • Published

Upload Mid Node

Upload Mid Node js file ExpressJS middleware to handle ´´´multipart/form-data´´´ which is used for uploading files.

Installation

$ npm install --save uploadmidnode

Usage

On your routes file include it with require then insert the check function such as:

var upload_mid_node = require('upload-mid-node');
 
app.post('/upload',
 
    // Upload middleware check
    upload_mid_node.check({
        options: global.config.public_folders.application.docs,
        supportedFileExt: ['txt', 'doc'],
        multiFiles: true
    }),
 
    // Next statement
    function (req, res) {
        res.status(200).send(req.uploads);
    }
);

Options:

global.config = {
    public_folders: {
        application: {
            docs: {
                path: "./public/documents",
                limitSize: 20000000
            }
        }
    }
};
  • path: It must contain the physical path which the file will be stored, also it will create a temp which is cleaned after store the files on the final path.
  • limitSize: The file size limit (KB);
  • supportedFileExt: Supported file extensions;

After the middleware route it to the next statement you can access all your uploaded file properties on req.uploads.

Testing

Here is a good place to make calls from a ready web app: Just change the action variable to your local server eg: http://localhost:PORT/upload

Any problem or suggestion get in touch.

License

MIT © Felipe Kautzmann

Package Sidebar

Install

npm i uploadmidnode

Weekly Downloads

0

Version

0.0.1

License

MIT

Last publish

Collaborators

  • felipekm