node.js - how to store images in the mongodb database as bindata using meteor? -


i did researches storing images in mongodb database using meteor , found code , blocked in before storing in database:

var fs = npm.require('fs');  // function encode file data base64 encoded string function base64_encode(file) {   // read binary data   var bitmap = fs.readfilesync(file);   // convert binary data base64 encoded string   return new buffer(bitmap).tostring('base64'); }    // convert image base64 encoded string   var base64str = base64_encode('chrysanthemum.jpg');   console.log(base64str); 

the problem npm.require('fs'); doesn't work in client side. if have solution or solution such plugin working in meteor bar progress (for multiple images using bindata) on how store images in mongodb, please me. thank in advance.

most common approach use collectionfs store data in mongo using built in gridfs feature. let work around 16mb document size limit. , provide set of various useful helper functions in client , server side.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -