We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 316bbef commit 394890cCopy full SHA for 394890c
src/base64ToFile.ts
@@ -0,0 +1,11 @@
1
+export function base64ToFile(s: string, filename: string): File {
2
+ const arr = s.split(','),
3
+ mime = arr[0]?.match(/:(.*?);/)?.[1],
4
+ bstr = atob(arr[1])
5
+ let n = bstr.length
6
+ const u8arr = new Uint8Array(n);
7
+ while (n--) {
8
+ u8arr[n] = bstr.charCodeAt(n);
9
+ }
10
+ return new File([u8arr], filename, { type: mime });
11
+}
0 commit comments