Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8178881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:52:25+00:00 2026-06-06T23:52:25+00:00

I’m using Node.js + Express to build a web application, and I find the

  • 0

I’m using Node.js + Express to build a web application, and I find the connect BodyParser that express exposes to be very useful in most cases. However, I would like to have more granular access to multipart form-data POSTS as they come – I need to pipe the input stream to another server, and want to avoid downloading the whole file first.

Because I’m using the Express BodyParser, however, all file uploads are parsed automatically and uploaded and available using "request.files" before they ever get to any of my functions.

Is there a way for me to disable the BodyParser for multipart formdata posts without disabling it for everything else?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T23:52:26+00:00Added an answer on June 6, 2026 at 11:52 pm

    When you type app.use(express.bodyParser()), almost each request will go through bodyParser functions (which one will be executed depends on Content-Type header).

    By default, there are 3 headers supported (AFAIR). You could see sources to be sure. You can (re)define handlers for Content-Types with something like this:

    var express = require('express');
    var bodyParser = express.bodyParser;
    
    // redefine handler for Content-Type: multipart/form-data
    bodyParser.parse('multipart/form-data') = function(req, options, next) {
      // parse request body your way; example of such action:
      // https://github.com/senchalabs/connect/blob/master/lib/middleware/multipart.js
    
      // for your needs it will probably be this:
      next();
    }
    

    upd.

    Things have changed in Express 3, so I’m sharing updated code from working project (should be app.useed before express.bodyParser()):

    var connectUtils = require('express/node_modules/connect/lib/utils');
    
    /**
     * Parses body and puts it to `request.rawBody`.
     * @param  {Array|String} contentTypes Value(s) of Content-Type header for which
                                           parser will be applied.
     * @return {Function}                  Express Middleware
     */
    module.exports = function(contentTypes) {
      contentTypes = Array.isArray(contentTypes) ? contentTypes
                                                 : [contentTypes];
      return function (req, res, next) {
        if (req._body)
          return next();
    
        req.body = req.body || {};
    
        if (!connectUtils.hasBody(req))
          return next();
    
        if (-1 === contentTypes.indexOf(req.header('content-type')))
          return next();
    
        req.setEncoding('utf8');  // Reconsider this line!
        req._body   = true;       // Mark as parsed for other body parsers.
        req.rawBody = '';
    
        req.on('data', function (chunk) {
          req.rawBody += chunk;
        });
    
        req.on('end', next);
      };
    };
    

    And some pseudo-code, regarding original question:

    function disableParserForContentType(req, res, next) {
      if (req.contentType in options.contentTypes) {
        req._body = true;
        next();
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.