I have been working on this for days now with no avail :( Any help would be greatly appreciated.
I am trying to download a file as a typed array using this method below:
var oReq = new XMLHttpRequest();
oReq.open("GET", "/myfile.png", true); //This is the path to my file
oReq.responseType = "arraybuffer";
oReq.onload = function (oEvent) {
var arrayBuffer = oReq.response;
var array = new Uint8Array(arrayBuffer ); //This is the array I retrieve from my file
};
oReq.send(null);
When I do this with all assets being on my computer's hard drive it works perfectly and I'll get a response back that looks like this (this is just example data):
array[0] = 10;
array[1] = 15;
array[2] = 20;
array[3] = 17;
array[4] = 18;
array[5] = 23;
array[6] = 25;
array[7] = 12;
array[8] = 2;
array[9] = 10;
...
However when I upload everything to the server I get a result that looks like this:
array[0] = 10;
array[1] = 15;
array[2] = 20;
array[3] = 17;
array[4] = 18;
array[5] = 25; //This number is missing from above, it should be 23
array[6] = 12;
array[7] = 2;
array[8] = 10;
array[9] = 18;
...
I have tried everything I can think of to fix this problem. Clearing the cache, turning gzip on and off, testing it with different devices (ie loading it on a phone and a computer), but nothing has been of any help so far.
What strikes me as odd is that the same numbers are consistently wrong every time. So I don't think they are getting "lost" over the network. Also when I test it with a different server I get different numbers that drop. So it seems like every server drops a different set of numbers.
Does anyone know why this is and could you lead me toward a direction to help fix the problem? Thank you so much!
fetch('/myfile.png').then(res=>res.arrayBuffer()).then(ab=>new Uint8Array(ab)).then(u => console.log(u))... does that also "miss" bytes?Content-Lengthheader changing too?