Is there any size limitation for \"data:\" URL scheme
values? I\'m interested in limitations in popular web browsers. In other words, how long can data:image/jpg;base6
I tried the code from waza123 but the charCodeAt
method did not convert all characters correctly. Here is my solution for creating large downloads in the browser. (I used it for JSON data)
function exportToFile(jsonData, fileName) {
const u8arr = new TextEncoder('utf-8').encode(JSON.stringify(jsonData, null, 2));
const url = window.URL.createObjectURL(new Blob([u8arr], { type: 'application/json' }));
const element = document.createElement('a');
element.setAttribute('href', url);
element.setAttribute('download', fileName);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}