My Angularjs app sends to Node.js-server an XML-string as POST-data.
var xmlString = (new XMLSerializer()).serializeToString(xmlData);
var fd = new FormData();
fd.append('xml', xmlString);
$http.post("/saveXML", fd, {
transformRequest: angular.identity,
headers: {'Content-Type': undefined}
}).success(function (response) {
console.log('xml uploaded!!', response);
}).error(function (error) {
console.log("Error while uploading the xml!");
});
and Node.js receives the data and writes it to a file.
app.post('/saveXML', function (request, response) {
var xmlData = request.body.xml;
console.log(request.body);
fs.writeFile("./uploads/mergedXml.xml", xmlData, function(wError){
if (wError) {
console.log(wError.message);
response.send({
success: false,
message: "Error! File not saved!"
});
throw wError;
}
console.log("success");
response.send({
success: true,
message: "File successfully saved!"
});
});
});
The problem is that if the sent XML-string (POST xml data) is larger than 1MB, it is truncated by Node.js(?) to 1MB. So that "mergedXml.xml" is then 1MB or exact 1024 Kb.
I use for Node.js: "express", "fs", "multer", "body-parser".
I've tried various settings for this, for example:
app.use(multer({
dest: './uploads/',
limits: {
fileSize: 999999999
}
}));
app.use(bodyParser.raw({limit: '10mb'}));
But they have not worked. What could be wrong here? Is this perhaps problem with angularjs POST method? I would be thankful for any help.