Skip to content

Commit 5b2b931

Browse files
committed
Created new downnload functions
1 parent 19f1214 commit 5b2b931

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

utils/download.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
export function downloadPNG(imgURL){
2+
const url = window.URL.createObjectURL(new Blob([imgURL]));
3+
const link = document.createElement("a");
4+
link.href = url;
5+
link.setAttribute("download", "qrCode.png"); //or any other extension
6+
document.body.appendChild(link);
7+
link.click();
8+
}
9+
10+
export function downloadSVG(imgURL){
11+
const url = window.URL.createObjectURL(new Blob([imgURL]));
12+
const link = document.createElement("a");
13+
link.href = url;
14+
link.setAttribute("download", "qrCode.svg"); //or any other extension
15+
document.body.appendChild(link);
16+
link.click();
17+
}
18+
19+
export function downloadJPG(imgURL){
20+
const url = window.URL.createObjectURL(new Blob([imgURL]));
21+
const link = document.createElement("a");
22+
link.href = url;
23+
link.setAttribute("download", "qrCode.jpg"); //or any other extension
24+
document.body.appendChild(link);
25+
link.click();
26+
}
27+

0 commit comments

Comments
 (0)