@meanie/multer-mime-types-filter

Helper to create a mime types filter for Multer given an array of mime types

Stats

StarsIssuesVersionUpdatedCreatedSize
@meanie/multer-mime-types-filter
102.0.12 years ago4 years agoMinified + gzip package size for @meanie/multer-mime-types-filter in KB

Readme

@meanie/multer-mime-types-filter

npm version node dependencies github issues codacy

Helper to create a mime types filter for Multer given an array of mime types

Meanie

Installation

You can install this package using yarn or npm.

#yarn
yarn add @meanie/multer-mime-types-filter

#npm
npm install @meanie/multer-mime-types-filter --save

Usage

const multer = require('multer');
const mimeTypesFilter = require('@meanie/multer-mime-types-filter');

/**
 * Upload middleware
 */
upload(req, res, next) {

  //Get locals
  const mimeTypes = ['image/jpeg', 'image/png', 'image/gif'];

  //Create upload middleware
  let upload = multer({
    storage: multer.memoryStorage(),
    fileFilter: mimeTypesFilter(mimeTypes),
  }).single('file');

  //Use middleware
  upload(req, res, next);
}

Issues & feature requests

Please report any bugs, issues, suggestions and feature requests in the @meanie/multer-mime-types-filter issue tracker.

Contributing

Pull requests are welcome! If you would like to contribute to Meanie, please check out the Meanie contributing guidelines.

Sponsor

This package has been kindly sponsored by Hello Club, an all in one club and membership management solution complete with booking system, automated membership renewals, online payments and integrated access and light control. Check us out if you happen to belong to any kind of club or if you know someone who helps run a club!

License

(MIT License)

Copyright 2016-2020, Adam Reis

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.