Fix convertTextToBase64 for large files Reference: https://github.com/google/closure-library/blob/b312823ec5f84239ff1db7526f4a75cba0420a33/closure/goog/crypt/crypt.js#L104-L123
| @@ -1469,7 +1469,11 @@ export function convertTextToBase64(text) { | ||
| 1469 | 1469 | return utf8Bytes.toBase64(); |
| 1470 | 1470 | } |
| 1471 | 1471 | // Creates binary string, where each character's code point directly matches the byte value (0-255). |
| 1472 | 1472 | constlet binaryString = String.fromCharCode(...utf8Bytes)''; |
| 1473 | + const chunkSize = 8192; | |
| 1474 | + for (let i = 0; i < utf8Bytes.length; i += chunkSize) { | |
| 1475 | + binaryString += String.fromCharCode(...utf8Bytes.subarray(i, i + chunkSize)); | |
| 1476 | + } | |
| 1473 | 1477 | return window.btoa(binaryString); |
| 1474 | 1478 | } |
| 1475 | 1479 | |