Javascript Fetch API with multiple range request get binary Float32Array data

I am using a range query to read a large 32 bit float from a large binary, unfortunately the plugin I need from this file is in a different part of the file, so I need to make a range query 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);
    });

      

Due to 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 is in different parts, I tried using Blob and FileReader to rotate the data into an arrayBuffer and wrap it with Float32Array, but with no success. May I ask how do I get the 32 bit float value from multiparts? Thank you so much for your help.

+3
javascript multipart blob arraybuffer


source to share


No one has answered this question yet

See similar questions:

4
Javascript / HTML5 API reading sequential files into polyphase form data
0
Extract the large file and automatically resume the network error (rather than starting over)

or similar:

740
HTTP GET request in JavaScript?
6
Reading a binary response using the Fetch API
4
How to load binary file during javascript unit test?
1
Send file binary from ajax to ashx file as application / octet-stream
1
multipart / mixed and application / octet-stream
1
Receiving and sending binary to Google Drive using Ajax request
1
How to parse multipart / byteranges responses correctly with typescript / javascript?
0
Mismatch between binary data sent with POST request and data received by Flask
0
nodejs for handling massive buffers
0
HTTP byte ranges and multipart / byteranges options?



All Articles
Loading...
X
Show
Funny
Dev
Pics