I have this package nodemailer used in Meteor. After getting the emails, I would like to save the attachments using Meteor Files. The problem is I don't know how. Can anyone provide a simple example for uploading files in server code. I tried uploading in the client and successful. But when i tried Files.insert() in server, it have "not a function" error.
Here is my code in server,
var mailparser = new MailParser({
streamAttachments: true
});
Fiber(function() {
var timeStamp = Math.floor(Date.now());
mailparser.on("attachment", function(attachment, mail){
... code here to upload
mailparser.on("end", Meteor.bindEnvironment(function (mail_object) {
.... some code here
}));
mailparser.write(data);
mailparser.end();
client.dele(msgnumber);
}).run();
Because insert function is for client side only, I used write() function of Files API. Here is the link, https://github.com/VeliovGroup/Meteor-Files/wiki/Write