i'm trying to send a file into Azure service file is not vailed when i send it i'm using https://html2canvas.hertzen.com/ to generate images
Azure documentation :https://docs.microsoft.com/en-us/rest/api/customvision/training3.3/create-images-from-files/create-images-from-files#examples
$(window).bind("load", function() {
html2canvas(document.querySelector(".classname"), {
scale: 2,
}).then(canvas => {
var imagedata = canvas.toDataURL('image/png', 1.0);
imagedata = imagedata.replace(/^data:image\/(png|jpg);base64,/, "");
// console.log(imagedata);
// var data = {};
// var imgagefile = data['image']=imagedata;
let resp = JSON.stringify(imagedata);
res = JSON.parse(resp);
$.ajax({
url: 'https://<stance-name>.cognitiveservices.azure.com/customvision/v3.3/training/projects/<project-id>/images/files',
headers: {
'Training-Key': '<Training-Key>',
'Content-Type': 'application/json'
},
method: 'POST',
dataType: 'json',
data: JSON.stringify({
"images":[
{
"name": "hemlock_10.png",
"contents":res ,
}
],
"tagIds": [
"<the_id-herer>"
]
},
),
success: function(data) {
// alert(data);
},
error: function(data) {
}
});
});
});
});
thank you