var base64 = '';
const blob = dataURLToBlob(base64);
const file = blobToFile(blob, 'image.jpg');
uploadImage(file);
function dataURLToBlob(base64) {
const parts = dataURL.split(';base64,');
const contentType = parts[0].split(':')[1];
const byteCharacters = atob(parts[1]);
const byteArrays = [];
for (let i = 0; i < byteCharacters.length; i++) {
byteArrays.push(byteCharacters.charCodeAt(i));
}
return new Blob([new Uint8Array(byteArrays)], { type: contentType });
}
function blobToFile(blob, fileName) {
return new File([blob], fileName, { type: blob.type });
}