I want to store an image browsed by a file input to database. I am browing the image using redactor plugin using this code
$('.editor').redactor({
imageUpload:"/uploads"
});
Using this when i select or browse an image i am directly sending that image to server using meteor HTTP-methods
HTTP.methods({
'/uploads': function(data) {
console.log(data)
Meteor.call("uploadImage",data)
return JSON.stringify({'Hello':"hello"});
}
});
Here when i am doing console.log data I am getting the 64bit binary code for the image. Now i want to save this data to the mongodb database.
I am using meteor-collection 2 for defining fields and their types. But i couldn't get which data type i have to use to store image to the mongo db.
I am trying to use mongodb gridfs to store the image. Tell me how can i store image in mongodb ? Thanx
Have a look at this package, it provides everything you need : https://github.com/CollectionFS/Meteor-CollectionFS
I use it to store file in Mongo in different app.