Skip to content

Commit

Permalink
fix: file2base64: support large files
Browse files Browse the repository at this point in the history
  • Loading branch information
Tardo committed Dec 11, 2024
1 parent d227230 commit a0638ed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

**11.7.2**

```
FIX: file2base64: Support large files
```

**11.7.1**

```
Expand Down
7 changes: 4 additions & 3 deletions src/js/page/terminal/utils/file2base64.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ export default function <T>(this: T): Promise<string> {
input_elm.onchange = e => {
const file = e.target.files[0];
const reader = new FileReader();
reader.readAsArrayBuffer(file);
reader.readAsDataURL(file);

reader.onerror = reject;
reader.onabort = reject;
reader.onload = readerEvent => {
reader.onload = (readerEvent) => {
// $FlowFixMe
resolve(btoa(String.fromCharCode(...new Uint8Array(readerEvent.target.result))));
const [_, base64] = readerEvent.target.result.split(',');
resolve(base64);
};
};
input_elm.click();
Expand Down

0 comments on commit a0638ed

Please sign in to comment.