【发布时间】:2015-02-24 03:43:10
【问题描述】:
我正在尝试通过我的流星收藏找到一种将 mp3 文件上传到 mongo 收藏中的方法。这有点具有挑战性,因为我最终将“C:\fakepath\audio.mp3”作为保存在集合中的内容。
非常感谢任何帮助。 谢谢。
【问题讨论】:
标签: html mongodb meteor html5-audio
我正在尝试通过我的流星收藏找到一种将 mp3 文件上传到 mongo 收藏中的方法。这有点具有挑战性,因为我最终将“C:\fakepath\audio.mp3”作为保存在集合中的内容。
非常感谢任何帮助。 谢谢。
【问题讨论】:
标签: html mongodb meteor html5-audio
您正在寻找FSCollection Package 和GridFS 存储适配器。
要开始在控制台上运行它。
meteor add cfs:standard-packages
meteor add cfs:gridfs
现在使用 fsCollection,您可以像这样简单地上传文件。
第一个
声明集合。
AudioCollection = new FS.Collection("AudioCollection", {
stores: [new FS.Store.GridFS("AudioCollection")]
});
创建一个简单的Event handler。
Template.example.events({
'click #example':function(e,t){
//Simple Event to upload files into mongo.
}
})
然后做一个简单的helper
Template.example.helpers({
showAudio:function(){
return AudioCollection.find();
}
})
有了这个HTML
{{each showAudio}}
{{#if isAudio}}
<!-- show whatever you want here -->
{{/if}}
{{/each}}
由于此时自述文件为空,我制作了一个示例DEMO。
【讨论】: