+
Skip to content

RangeError: Maximum call stack size exceeded. #137

Closed
@smakinson

Description

@smakinson

I am using your lib to upload images to github and I came across this error "RangeError: Maximum call stack size exceeded." in chrome & safari when uploading. I found this discussion:

http://stackoverflow.com/questions/3195865/converting-byte-array-to-string-in-javascript

and I tried the suggestion in lovasoa's toBinString function and changed the code around line 366 from:

content = {
"content": btoa(String.fromCharCode.apply(null, new Uint8Array(content))),
"encoding": "base64"
};

to

var uarr = new Uint8Array(content);
var strings = [], chunksize = 0xffff;
var len = uarr.length;

// There is a maximum stack size. We cannot call String.fromCharCode with as many arguments as we want
for (var i = 0; i * chunksize < len; i++){
strings.push(String.fromCharCode.apply(null, uarr.subarray(i * chunksize, (i + 1) * chunksize)));
}

content = {
"content": btoa(strings.join('')),
"encoding": "base64"
};

It seems to work now. I have not done tons of testing, but I thought I'd file a bug if someone has some time to check it out.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载