I have multipart/form-data
that I am posting to an express endpoint /data/upload
, form markup below:
form(enctype=\"multipart/form-data
For the answer of Afanasii Kurakin
request.post({
url: server.baseURL + 'api/data',
formData: {
file: {
value: fileStream,
options: {
knownLength: req.headers['content-length']
}
}
}
}, function (err, r, body) {
// Do rendering stuff, handle callback
})
You should change from req.headers['content-length']
to the real file size, normally the content-length from header is bigger than the file size. I got pain because of the content-length and after using the file size, everything worked perfectly.