Search code examples
javascriptarraybuffer

maximum call stack size exceeded on converting file


I am converting a large byte array into a string using

 var arrayBuffer = e.target.result,
          array = new Uint8Array(arrayBuffer);
 binaryString = String.fromCharCode.apply(null, array);

Here e.target.result is a image. It is working properly but if image size is bigger i'll get error maximum call stack size exceeded. How can i resolved this ??

Thanks in advance........


Solution

  • var base64 = btoa(new Uint8Array(arrayBuffer).reduce(
        function (data, byte) {
            return data + String.fromCharCode(byte);
        },
        ''
    ));