fix: remove iOS saveFile workaround #20

This commit is contained in:
Paul Zeinlinger 2021-07-08 23:05:39 +02:00
parent 1520942ac9
commit b9292abefe
No known key found for this signature in database
GPG Key ID: C95079BFAABD4E98

View File

@ -224,24 +224,6 @@ async function saveFile(file) {
if (navigator.msSaveBlob) { if (navigator.msSaveBlob) {
navigator.msSaveBlob(blob, file.name); navigator.msSaveBlob(blob, file.name);
return resolve(); return resolve();
} else if (/iPhone|fxios/i.test(navigator.userAgent)) {
// This method is much slower but createObjectURL
// is buggy on iOS
const reader = new FileReader();
reader.addEventListener('loadend', function() {
if (reader.error) {
return reject(reader.error);
}
if (reader.result) {
const a = document.createElement('a');
a.href = reader.result;
a.download = file.name;
document.body.appendChild(a);
a.click();
}
resolve();
});
reader.readAsDataURL(blob);
} else { } else {
const downloadUrl = URL.createObjectURL(blob); const downloadUrl = URL.createObjectURL(blob);
const a = document.createElement('a'); const a = document.createElement('a');