How to store binary encoded image on mongodb

26 views
Skip to first unread message

Sarfraz Ahmad

unread,
Jan 1, 2014, 1:38:54 AM1/1/14
to mongod...@googlegroups.com

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

Reply all
Reply to author
Forward
0 new messages