1

I am trying to find a way to upload an mp3 file into a mongo collection through my meteor collection. Its a bit challenging as I end up with "C:\fakepath\audio.mp3" as what is saved in the collection.

Any help is greatly appreciated. Thanks.

Ally Jr
  • 938
  • 1
  • 13
  • 23

1 Answers1

3

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.

Community
  • 1
  • 1
Ethaan
  • 10,956
  • 5
  • 30
  • 42
  • Thanks! works! Since you seem to know your stuff and there isn't much out there... Is there a way I can control helpers from my events? – Ally Jr Feb 24 '15 at 05:35