title: multer stop file upload immediate on validation fail
body: <p>I am working on mean stack application and I face one issue with file uploading.</p>
  
  <p>I want to stop all uploading immediately as soon as the <code>global.isProcessKilled</code> variable is <code>true</code>.</p>
  
  <p>My code is as bellow</p>
  
  <p><strong>photo.js</strong></p>
  
  <pre><code>var express = require("express");
  var app = express()
  var router = express.Router();
  var multer = require("multer");
  var mongoose = require("mongoose");
  var fs = require("fs");
  var jwt = require("jsonwebtoken");
  var lib = require("../../../config/lib");
  
  var storage = multer.diskStorage({
      destination: function(req, file, cb) {
          cb(null, dirPath);
      },
      filename: function(req, file, cb) {
          var datetimestamp = Date.now() + Math.floor(Math.random());
          cb(null, datetimestamp + '.' + file.originalname.split('.')[file.originalname.split('.').length - 1].toLowerCase());
      }
  });
  
  var photoUpload = multer({ 
      storage: storage,
      fileFilter : function (req, file, cb) {
          if(global.isProcessKilled){ //my custom validation flag
                  // To reject this file pass `false`, like so:
                  cb(null, false);
          }else{
              // To accept the file pass `true`, like so:
              cb(null, true);    
          }
      }
  });
  
  router
      .route("/api/photo/photoUpload")
      .post(
          photoUpload.array("file"),        
          function(req, res) {
              .....
              .....
              ....
          });
  </code></pre>
  
  <p>By this code file uploading is working fine but my next original API call occurs only after processing the current(previous) file.</p>
  
  <p>More information:
  All selected files are more than 1mb and less than 10mb</p>
  
  <ul>
  <li>Step 1 : upload 30 file simultaneously</li>
  <li>Step 2 : the process will start</li>
  <li>Step 3 : suppose <code>global.isProcessKilled</code> variable will be <code>true</code> at 10 files</li>
  <li>Step 4 : next all files will not process for upload because of filter</li>
  <li>Step 5 : but the previous file means 9th file is running and I don't know how to stop it</li>
  <li>Step 6 : the process will not call next callback until file no 9th will not be uploaded and it takes about 2min</li>
  <li>Step 7 : for this reason api response I too delay</li>
  </ul>
  
  <p>Please help me to resolve this issue.  </p>