I am trying to write canvas data using node.js as binary . The file is JPEG, but after the file is written, I see that the file is stored as plain text, not binary data. fs.writeFile fs.writeFile
This is an example datasent by the client to my site representing JPEG image data (just the first few characters):
/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAFA3PEY8MlBGQUZaVVBfeM...
I get these data on the client side by doing:
canvas.toDataURL('image/jpeg', 0.5).replace('data:image/jpeg;base64,', '')
Here is the use of the function on my node.js server :
fs.writeFile('../some.jpeg', data, 'binary', function(err){});
Instead of writing the file in binary form ( ๏ขืด๏ขืด๏ข JFIF...), it records exactly the data that it received from the client.
What am I doing wrong here?