I have image data and I want to send this to API as binary.
var formData = new FormData();
formData.append("data",{"test":1});
//make jpg image from canvas.
var image = ref_canvas_release.current.toDataURL('image/jpeg', 0.85);
//////// confirm and test the image file is correctly created. it created and downloaded successfully.
var a = document.createElement('a');
a.href = image;
a.download = 'test.jpg';
a.click();
////////
formData.append("file",image);
axios.post("/myuploader",formData,{headers: {'Content-Type': 'application/form-data'}}).then(res=>{
console.log(res)
});
In this case, payload (on googld chrome developper console) shows like this,
The file is sent like this below.
file: data:image/jpeg;base64, /9j/.....
However I want to send the data as binary,
(if so payload screen is supposed to be)
file: binary
How can I change the format to send the API?