The extension crashes when it executes such code:
/*this object is created in content script and passed t background script*/
var myurl = URL.createObjectURL(document.getElementById('myfile').files[0]);
/*code block from background script, it work good if file size is < 50MB, if bigger then extension will crash*/
var x = new XMLHttpRequest();
x.onload = function() {
var uploadfile = new Uint8Array(x.response);
var somearray1 = [...];
var somearray2 = [...];
var size = somearray1.length + uploadfile.length + somearray2.length;
var u8array = new Uint8Array(size);
var i = 0;
for (i = 0; i < somearray1.length; i++)
u8array[i] = somearray1.charCodeAt(i) & 0xff;
for (var j = 0; j < uploadfile.length; i++, j++)
u8array[i] = ufile[j];
for (i = 0; i < somearray2.length; i++)
u8array[i] = somearray2.charCodeAt(i) & 0xff;
var req = new XMLHttpRequest();
req.open("POST", Url);
req.setRequestHeader("Content-Type", 'multipart/form-data; boundary=--_BOUNDARY_');
req.send(u8array);
};
x.open('GET', myurl);
x.responseType = 'arraybuffer';
x.send();
I want to upload a file of 200MB size, and it crashes the extension. Please help me understand with some sample code how to upload it correctly if it is wrong the way i'm doing now.