I'm in a Hackathon and we have to use IBM Bluemix technologies. We are all new to NodeJs and IBM Bluemix.
We need to upload this XML (there are also TTL, RDF and N3 formats) in the way to create a db and upload everything into it.
Do you have any suggestion on how to do this?
The following example and code assume you are using Express 3. Express 4 is a little different with body parsing...
Store the JSON in your DB.
app.post("/upload", function (request, response) {
async.waterfall(
[
function (next) {
//where leads is the name of the field from your html page
fs.readFile(request.files.leads.path, next);
},
function (xml, next) {
var json = parser.toJson(xml);
db.insert(json, next)
},
], function (error) {
if (error) {
console.log(error);
response.send(error);
return;
}
response.redirect("/");
}
);
});