Skip to content

Commit

Permalink
Updated SaveAs function
Browse files Browse the repository at this point in the history
  • Loading branch information
Balearica committed Aug 30, 2024
1 parent e8c6ea9 commit 200bad4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions js/utils/miscUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ export function countSubstringOccurrences(string, subString, allowOverlapping, c
* Modified version of code found in FileSaver.js.
*
* @global
* @param {string|ArrayBuffer} content
* @param {string|ArrayBuffer|Blob} content
* @param {string} fileName - File name.
*/
export const saveAs = async (content, fileName) => {
Expand All @@ -265,7 +265,12 @@ export const saveAs = async (content, fileName) => {
return;
}

const blob = new Blob([content], { type: 'application/octet-stream' });
let blob;
if (typeof Blob !== 'undefined' && content instanceof Blob) {
blob = content;
} else {
blob = new Blob([content], { type: 'application/octet-stream' });
}

const a = document.createElement('a');
a.download = fileName;
Expand Down

0 comments on commit 200bad4

Please sign in to comment.