I have a Meteor app where I'd like to upload a text file then have the file parsed on the server. I'm using cfs:gridfs
(with cfs:standard-package
, of course) to store the files on the server.
Client code:
Template.uploadPathway.events({
"submit #upload-pathway": function (event) {
event.preventDefault(); // prevent default browser form submit
var pathwayFile = event.target.pathwayFile.files[0];
UploadedFiles.insert(pathwayFile, function(error, fileObject) {
// error handling removed for brevity
Meteor.call("parseFile", fileObject._id);
});
}
});
Server code (in server folder, not Meteor.isServer):
Meteor.methods({
parseFile: function (fileId) {
var theFile = UploadedFiles.findOne({ _id: fileId });
console.log(theFile);
// how do I parse this file??
}
});
The above code works beautifully, but I have no idea how to read the data inside the FS.File