meteor upload a file to mongodb

泪湿孤枕 提交于 2019-12-03 21:25:06
Ethaan

You are looking for the FSCollection Package, and the GridFS Storage Adapter.

to get started run this on the console.

meteor add cfs:standard-packages

meteor add cfs:gridfs

now With fsCollection you can upload files simple as.

First

Declare the Collection.

AudioCollection = new FS.Collection("AudioCollection", {
  stores: [new FS.Store.GridFS("AudioCollection")]
});

Create a simple Event handler.

Template.example.events({
  'click #example':function(e,t){
    //Simple Event to upload files into mongo.
  }
})

And do a simple helper

Template.example.helpers({
 showAudio:function(){
   return AudioCollection.find();
  }
})

With this HTML

{{each showAudio}}
  {{#if isAudio}}
   <!-- show whatever you want here -->
  {{/if}}
{{/each}}

Since the README its empty at this moment i made a sample DEMO.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!