I am trying to read a file on the client side as an array buffer. Here is my code.
for (var index = 0; index < input.files.length;index++) {
let reader = new FileReader();
console.log(input.files[index].name);
reader.onload = () => {
var data:ArrayBuffer = reader.result;
console.log(data.toString().length);
}
reader.readAsArrayBuffer(input.files[index])
}
However my editor complains that reader.result returns (string | ArrayBuffer)
However if I remove type type from the data. I am unable to use ArrayBuffer specific methods like byteLength.
How do I force the reader.result to be an ArrayBuffer?