Im trying to build a web gui for a canon eos 7d using node.js (0.10.20), libgphoto2 (2.5.2.) and gphoto2 module for node on a Raspberry Pi (latest raspbian).
Everything seems to work fine except for saving the files in node.
im using the following code snippet:
app.get('/shoot', function(req, res){
camera.takePicture({download:true}, function(er, data){
res.header('Content-Type', 'image/jpeg');
res.send(data);
fs.writeFile("public/images/sampleImg.jpg", data);
});
});
The file created is unreadable/not a valid jpg image
using the cli tool for libgphoto creates a valid image:
pi@raspi /srv/node/eos $ gphoto2 --capture-image-and-download
so i assume the error is somewhere in the node-code for saving data
how would i properly save the data in node to a .jpg file?