Limit express-busboy to specific routes Limit express-busboy to specific routes express express

Limit express-busboy to specific routes


In allowedPath value you can specify regex in this case limit at post route defined in express application. likes /uploads

busboy.extend(app, {    upload: true,    path: './uploads/temp',    allowedPath: /^\/uploads$/});

or other wise you can pass function

var options = {        upload: true,        path: './uploads/temp',    };options.allowedPath = function(url) {    return url == '/api/ccUpload';}    busboy.extend(app, options);


Well since express-busboy wasn't working for me, I tried using express-fileupload instead and that seems to work now.


Try using Multer instead, and limit it to your route:

app.post('/^\/api\/ccUpload$/',  multer({    dest: './uploads/temp',    rename: function(fieldname, filename, req, res) {      return filename.toLowerCase();    }  }),  yourRouteHandler);