I'm writing a handler for accessing binary data. Currently I'm doing this:
...
d = new FileReader();
d.onload = function (e) {
var response_buffer, data, byte_len, temp_float;
response_buffer = e.target.result;
data = new DataView(response_buffer);
byte_len = data.byteLength;
// create empty placeholder for binary data received
tmp_data = new Float32Array(byte_len / Float32Array.BYTES_PER_ELEMENT);
len = tmp_data.length;
// Pre-parse
for (i = 0; i < len; i += 1) {
tmp_data[i] = data.getFloat32(i * Float32Array.BYTES_PER_ELEMENT, true);
}
...
Which works fine and "pre-processes" my fetched data (file/http) into my tmp_data array.
However I need to be able to handle large files as well (like 1GB+). My idea was to try and fetch only part of the file because from the binary structure I would know exactly what offsets I would have to fetch.
Question:
Is it possible to XHR for a "range" of bytes from a large file if I know offset and length instead of having to fetch the whole file?
Thanks!