diff options
| author | crupest <crupest@outlook.com> | 2021-03-11 22:54:12 +0800 |
|---|---|---|
| committer | crupest <crupest@outlook.com> | 2021-03-11 22:55:54 +0800 |
| commit | 5742cdaf5a0285725b630a769626c7f72cf635d8 (patch) | |
| tree | 6644b0c578520e0c82da413ab0a78f0cc7a7ca74 /FrontEnd/src/app/http | |
| parent | e7f77171541b4e008886b2f03a3d897e5e64eed5 (diff) | |
| download | timeline-5742cdaf5a0285725b630a769626c7f72cf635d8.tar.gz timeline-5742cdaf5a0285725b630a769626c7f72cf635d8.tar.bz2 timeline-5742cdaf5a0285725b630a769626c7f72cf635d8.zip | |
refactor: Improve base64.
Diffstat (limited to 'FrontEnd/src/app/http')
| -rw-r--r-- | FrontEnd/src/app/http/common.ts | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/FrontEnd/src/app/http/common.ts b/FrontEnd/src/app/http/common.ts index ef9a505e..5006109d 100644 --- a/FrontEnd/src/app/http/common.ts +++ b/FrontEnd/src/app/http/common.ts @@ -61,7 +61,11 @@ export function setHttpToken(token: string | null): void { } } -export function base64(blob: Blob): Promise<string> { +export function base64(blob: Blob | string): Promise<string> { + if (typeof blob === "string") { + return Promise.resolve(btoa(blob)); + } + return new Promise<string>((resolve) => { const reader = new FileReader(); reader.onload = function () { |
