Multipart form parse error - Invalid boundary in multipart: None

Karan picture Karan · Feb 17, 2016 · Viewed 8.8k times · Source

I am very frustrated and could not find the soloution:

I am creating a project using angularjs and nodejs.I get image data from angular side in node js and send this data to further api.I got error

{
  "error": {
    "detail": "Multipart form parse error - Invalid boundary in multipart: None"
  }
}

here is my code in nodejs side:

var request = require('request');
    console.log(req.files);
var data = {

        website:'www.gamail.xom',
        contact_number:'dsdsd',
        services_offered:'dsadasd',
        contact_name:'dasdas',
        provider_category:'exchange',
        email:'[email protected]',
        image:req.files

    }
var api_url = global.common.base_url + 'vcard/1.0.0/visit_card/' + req.param('uuid') +'/';
    request({
        url: api_url,
        method: 'PUT',
        headers: {
            'Content-Type': 'multipart/form-data',
            'Authorization': 'Bearer '+req.cookies.apitoken
        },
        json: data

    }, function(error, response, body) {
        if(response.statusCode == 200 && !error){
            res.end(JSON.stringify(body));
        }else{          
            res.send(response.statusCode, { error: body });
        }
    });
}

In req.files i get

{ image:
   [ { fieldName: 'image[0]',
       originalFilename: 'icon_dd_chart_grey.png',
       path: 'C:\\Users\\karakuma\\AppData\\Local\\Temp\\op74_gLSzPs-_49aT1GF0si
7.png',
       headers: [Object],
       size: 1474,
       name: 'icon_dd_chart_grey.png',
       type: 'image/png' } ] }

Answer

Aamir Five picture Aamir Five · Oct 2, 2017

Try defining the content type as follows.

content_type='multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW'

I was facing the same issue and it worked for me in python.