Read/write binary data to MongoDB in Node.js
问题 I've been able to successfully write binary data (an image) to MongoDB in Node.js. However I can't find clear documentation on how to read it back. Here's how I'm writing the image to MongoDB: var imageFile = req.files.myFile; var imageData = fs.readFileSync(imageFile.path); var imageBson = {}; imageBson.image = new db.bson_serializer.Binary(imageData); imageBson.imageType = imageFile.type; db.collection('images').insert(imageBson, {safe: true},function(err, data) { I'd appreciate any