I am looking for a client-side only JavaScript solution that can receive a large binary file from HTTP server to my web client in a streaming style, in which way I can response immediately as soon as I get package of data without having to wait all of them loaded into memory, and I can even discard the data after processing each of them so as to reduce memory footprint.
I searched online, and found it seems not possible via XMLHttpRequest, because of two reasons (quote from this article),
- XHR prevents to access the binary response (with arraybuffer response type) data before the request is complete.
- XHR response is essentially one big buffer that keeps growing linearly as the response data comes in which means it can't get garbage collected.
I wonder whether this can be achieved via websocket by any chance, and is there any good open sources that already solve this issue? I found some that seems relevant, such as Oboe.js and Binary.js, but it either cope with JSON streaming or need server side support.
Aucun commentaire:
Enregistrer un commentaire