How to convert a large uint8 Array to base64 encoded string

521 views Asked by At

This differs from caio keto's question as I'm dealing with large arrays and none of the proposed solutions for his question works for me. I'm trying to convert a very large uin8array to base64 like this:

const encodedString = Buffer.from(veryLargeArray.buffer).toString("base64");

For smaller arrays this works fine, but for the larger ones the code block runs for 5-7 seconds and then crashes. I've tried, among other solutions, using this byte-base64 function as well as a chunk splitting solution proposed by chatgpt, but it still crashes:

enter image description here

Any idea how I might solve this issue?

0

There are 0 answers