I'm running into a buffer overflow when I try to pull image data from mongoDB and try to convert it into base64. I know that storing images in mongo is not optimal, but I would like to do it, just to do it.
Here's the error that I'm receiving:
'start-server' errored after 6.28 s
[22:21:05] Error: stdout maxBuffer exceeded
at Socket.<anonymous> (child_process.js:255:14)
at emitOne (events.js:90:13)
at Socket.emit (events.js:182:7)
at readableAddChunk (_stream_readable.js:153:18)
at Socket.Readable.push (_stream_readable.js:111:10)
at Pipe.onread (net.js:529:20)
Here's the route that calls and transforms the data:
app.get('/api/photos', function (req, res) {
var photos = Photo.find({}, function(err, photos) {
if(photos.length != 0){
var photosData = [];
for(var i = 0; i < photos.length; i++){
var thumb = new Buffer(photos[i].img.data).toString('base64');
photosData.push(thumb);
}
res.json({info: 'it worked',
photos: photosData
});
}else{
res.json({info: 'it worked',
photos: false
});
}
});
})