I did researches about storing images in a mongodb database using meteor and I found this code and I get blocked in it before storing in the database:
var fs = Npm.require('fs');
// function to encode file data to base64 encoded string
function base64_encode(file) {
// read binary data
var bitmap = fs.readFileSync(file);
// convert binary data to base64 encoded string
return new Buffer(bitmap).toString('base64');
}
// convert image to base64 encoded string
var base64str = base64_encode('Chrysanthemum.jpg');
console.log(base64str);
The problem is that Npm.require('fs'); doesn't work in the client side. If you have a solution for this or another solution such as a plugin working in meteor with a bar progress (for multiple images using bindata) on how to store images in mongodb, please help me. Thank you in advance.