I\'m trying to write a canvas data with node.js fs.writeFile as a binary. JPEG file, but after the file is written I can see that the file is stored as plain text, not binar
Instead of writing the file directly to your client, first, ask the server to send images in binary format.
let request= {
headers: {
'Content-Type': 'image/jpeg',
'Authorization': "your token"
},
encoding:'binary'
};
request.get(url,request,(error, response, body)=>{
if(error){
console.log('error in get photo',error)
return "default image to server";
}else{
if(response.statusCode == 200){
Fs.writeFile('path',body,'binary',function(err){
if(err){
return "your message";
}else{
return "success";
}
})
}else{
console.log('error in get photo 3')
return "your message";
}
}
})