Extract saveURLAsFile
This commit is contained in:
parent
4c0c55082f
commit
307ab0d3a5
1 changed files with 17 additions and 0 deletions
17
ts/util/saveURLAsFile.ts
Normal file
17
ts/util/saveURLAsFile.ts
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
/**
|
||||||
|
* @prettier
|
||||||
|
*/
|
||||||
|
export const saveURLAsFile = ({
|
||||||
|
filename,
|
||||||
|
url,
|
||||||
|
document,
|
||||||
|
}: {
|
||||||
|
filename: string;
|
||||||
|
url: string;
|
||||||
|
document: Document;
|
||||||
|
}): void => {
|
||||||
|
const anchorElement = document.createElement('a');
|
||||||
|
anchorElement.href = url;
|
||||||
|
anchorElement.download = filename;
|
||||||
|
anchorElement.click();
|
||||||
|
};
|
Loading…
Add table
Add a link
Reference in a new issue