Skip to content

Commit 2881274

Browse files
author
Simon he
committed
chore: add fileToBase64
1 parent 31da66d commit 2881274

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/fileToBase64.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export function fileToBase64(file: File) {
2+
return new Promise((resolve, reject) => {
3+
let reader = new FileReader();
4+
reader.readAsDataURL(file)
5+
reader.onload = function (e) {
6+
resolve(e?.target?.result)
7+
}
8+
})
9+
}

0 commit comments

Comments
 (0)