meteor 上传一个文件到 mongodb
meteor upload a file to mongodb
我正在尝试找到一种通过我的流星 collection 将 mp3 文件上传到 mongo collection 的方法。这有点挑战,因为我最终将 "C:\fakepath\audio.mp3" 保存在 collection.
中
非常感谢任何帮助。
谢谢
您正在寻找 和 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}}
由于此时 README 是空的,我做了一个示例 DEMO。
我正在尝试找到一种通过我的流星 collection 将 mp3 文件上传到 mongo collection 的方法。这有点挑战,因为我最终将 "C:\fakepath\audio.mp3" 保存在 collection.
中非常感谢任何帮助。 谢谢
您正在寻找 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}}
由于此时 README 是空的,我做了一个示例 DEMO。