Spaces:
Configuration error
Configuration error
Download frontend/src/utils/base64-to-blob.ts from flyingdarkdev/README: direct link, hf CLI and curl.
- Browser
- Download file 718 Bytes
-
https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/frontend/src/utils/base64-to-blob.ts
- Command line
-
hf download hf://spaces/flyingdarkdev/README/frontend/src/utils/base64-to-blob.ts
-
curl -L -o base64-to-blob.ts https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/frontend/src/utils/base64-to-blob.ts
718 Bytes
| export const base64ToBlob = (base64: string) => { | |
| // Remove the prefix (e.g. data:image/png;base64,) | |
| const base64WithoutPrefix = base64.split(",")[1] || base64; | |
| // Decode to bytes | |
| const bytes = atob(base64WithoutPrefix); | |
| // Process in chunks to avoid memory issues | |
| const chunkSize = 8192; // Process 8KB at a time | |
| const chunks = []; | |
| for (let i = 0; i < bytes.length; i += chunkSize) { | |
| const chunk = bytes.slice(i, i + chunkSize); | |
| const array = new Uint8Array(chunk.length); | |
| for (let j = 0; j < chunk.length; j += 1) { | |
| array[j] = chunk.charCodeAt(j); | |
| } | |
| chunks.push(array); | |
| } | |
| // Create a Blob from all chunks | |
| return new Blob(chunks, { type: "application/zip" }); | |
| }; | |