I am using range request to read many 32 bit float from a large binary file, unfortunately the float I need from this file is at different part of the file, hence I need to do range request with multiple ranges
fetch("http://example.com/largeBinaryFile.bin", {
headers: {
'content-type': 'multipart/byteranges',
'range': 'bytes=2-5,10-13',
},
})
.then(response => {
if (response.ok) {
return response.text();
}
})
.then(response => {
console.log(response);
});
Because of the multiple ranges, I have to use text instead of arrayBuffer, and when I print out the response I get
--00000000000000000002
Content-Type: application/octet-stream
Content-Range: bytes 2-5/508687874
1ȹC
--00000000000000000002
Content-Type: application/octet-stream
Content-Range: bytes 10-13/508687874
þC
--00000000000000000002--
As you can see, the binary data are in different parts, I have tried using Blob and FileReader to turn the data into arrayBuffer and wrap it with Float32Array but with no success. May I ask how do I get the 32 bit float value from the multiparts? Thank you so much in advance for your help.