mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-13 20:00:05 +01:00
Convert url to blob for large file size download (#1455)
* Convert url to blob for large size download * Replaced var with let Co-authored-by: Harsh Khandeparkar <34770591+HarshKhandeparkar@users.noreply.github.com> Co-authored-by: Jeffrey Warren <jeff@unterbahn.com>
This commit is contained in:
@@ -339,11 +339,23 @@ function DefaultHtmlStepUi(_sequencer, options) {
|
||||
|
||||
$stepAll('.download-btn').on('click', () => {
|
||||
|
||||
function dataURLtoBlob(dataurl) {
|
||||
let arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1],
|
||||
bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
|
||||
while(n--){
|
||||
u8arr[n] = bstr.charCodeAt(n);
|
||||
}
|
||||
return new Blob([u8arr], {type:mime});
|
||||
}
|
||||
|
||||
var element = document.createElement('a');
|
||||
element.setAttribute('href', step.output);
|
||||
|
||||
element.setAttribute('download', step.name + '.' + fileExtension(step.imgElement.src));
|
||||
element.style.display = 'none';
|
||||
document.body.appendChild(element);
|
||||
var blob = dataURLtoBlob(step.output);
|
||||
var objurl = URL.createObjectURL(blob);
|
||||
element.setAttribute('href', objurl);
|
||||
|
||||
element.click();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user