In my code, I have a function that is responsible for downloading chunks of a file using an xhr request. The function is structured like this:
var blobXHR = new XMLHttpRequest();
//api.media.chunkURL() returns the correct URL for each chunk
blobXHR.open("GET", api.media.chunkURL({
fileId: fileID,
chunkId: chunkNumber
}));
blobXHR.responseType = "arraybuffer";
blobXHR.onerror = function (e) {
console.log("Error: ", e);
};
var arrayBuffer;
blobXHR.onload = function (e) {
arrayBuffer = blobXHR.response;
};
blobXHR.send();
This download function runs smoothly on Chrome, Firefox, and most Android browsers. However, I encounter a vague error specifically on Safari and iOS browsers within the blobXHR.onerror() function. The error message I receive is:
Error: InvalidStateError: DOM Exception 11
Despite researching similar issues, I have not found a solution that works for me. Can anyone shed light on why this problem is occurring only on Safari and iOS browsers?
Additional note: When I console.log(blobXHR) within onerror(), I get the following output: