使用 Meteor Files veliov group 在服务器中上传文件
Upload files in server using Meteor Files veliov group
我在 Meteor 中使用了这个包 nodemailer。
收到电子邮件后,我想使用 Meteor Files 保存附件。
问题是我不知道怎么做。任何人都可以提供一个在服务器代码中上传文件的简单示例。我尝试在客户端上传并成功。但是当我在服务器中尝试 Files.insert() 时,它有 "not a function" 错误。
这是我在服务器中的代码,
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();
因为insert函数仅供客户端使用,所以我使用了Files的write()函数API。这里是 link,
https://github.com/VeliovGroup/Meteor-Files/wiki/Write
我在 Meteor 中使用了这个包 nodemailer。 收到电子邮件后,我想使用 Meteor Files 保存附件。 问题是我不知道怎么做。任何人都可以提供一个在服务器代码中上传文件的简单示例。我尝试在客户端上传并成功。但是当我在服务器中尝试 Files.insert() 时,它有 "not a function" 错误。
这是我在服务器中的代码,
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();
因为insert函数仅供客户端使用,所以我使用了Files的write()函数API。这里是 link, https://github.com/VeliovGroup/Meteor-Files/wiki/Write