Skip to content

Commit

Permalink
Blob arrayBuffer base64 file blobUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
saqqdy committed Oct 28, 2023
1 parent c7a4583 commit 47b213c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/arrayBufferToBase64.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
function arrayBufferToBase64(input: ArrayBuffer, mime = 'image/png') {
const u8Array = String.fromCharCode(...new Uint8Array(input))
return `data:${mime};base64,${window.btoa(u8Array)}`
return `data:${mime};base64,${btoa(u8Array)}`
}

export default arrayBufferToBase64
2 changes: 1 addition & 1 deletion src/base64ToArrayBuffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function base64ToArrayBuffer(input: string): ArrayBuffer {
}

if (inBrowser) {
const bstr = window.atob(data)
const bstr = atob(data)
let len = bstr.length
const u8Array = new Uint8Array(len)
while (len--) {
Expand Down
2 changes: 1 addition & 1 deletion src/urlToBlob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
function urlToBlob(input: string): Promise<Blob | null> {
return new Promise((resolve, reject) => {
if (!window.fetch) {
if (!fetch) {
const xhr = new XMLHttpRequest()
xhr.open('get', input, true)
xhr.responseType = 'blob'
Expand Down

0 comments on commit 47b213c

Please sign in to comment.