meteorFS.Collection访问服务器上的集合

我正在使用FS.Collection在服务器上传短video文件,然后作为电子邮件中的附件发送。

插入服务器上的集合工作,我可以访问客户端上的集合项目,也可以直接使用文件的pathUrl – localhost:3000/cfs/files/videos/{{item_id}}

我不知道如何访问服务器上的收集。 我想以下面的forms发送带有附件的电子邮件,并需要访问服务器上文件和文件名的path。 我试过了:

 Email.send({ to: to, from: from, subject: subject, text: text, attachments:[{fileName:"video.mp4", filePath:"/cfs/files/videos/{{item_id}}"}] }); 

它显示电子邮件中的附件video播放器,但有错误消息,所以我假设我没有正确访问文件。

我的Collection.js很简单:

 var videoStore = new FS.Store.GridFS("videos"); Videos = new FS.Collection("videos", { stores: [videoStore] }); 

您不能使用collectionFS的filePath附件。 “/ cfs / files / videos / {{item_id}}”是一个虚拟path,即文件不存在于/ cfs / files / videos中,也不存在文件夹'/ cfs / files / videos'。

您可以改为使用httppath:

 var ROOT_URL = process.env.ROOT_URL; var rootUrl; if (ROOT_URL.indexOf('/', ROOT_URL.length - 1) != -1) { rootUrl = ROOT_URL.substring(0, ROOT_URL.length - 1); } else { rootUrl = ROOT_URL; } var attachments = []; attachment = { fileName: fileName(url), filePath: rootUrl + "/cfs/files/videos/{{item_id}}" }; attachments.push(attachment); Email.send({ to: to, from: from, subject: subject, text: text, attachments: attachments });