3

JS code construct multiply Blob data, like:

var b1 = new Blob([..40M..]);
var b2 = new Blob([..40M..]);
var b3 = new Blob([..40M..]);

I want to merge b1, b2, b3 into a single 120M data and save it as a file, but the memory is of high cost.

Is there any solution to store it in a efficient way, like:

downloadFile.append(b1);
downloadFile.append(b2);
downloadFile.append(b3);
Mohammad
  • 21,175
  • 15
  • 55
  • 84
ghostplant
  • 87
  • 1
  • 7
  • Blobs are "immutable" so you can't change one after making it. – ale Jun 07 '16 at 09:35
  • Possible duplicate of [Appending Blob data](http://stackoverflow.com/questions/15970729/appending-blob-data) – ale Jun 07 '16 at 09:35
  • Yes, you are right the questions are same! However, when I receive b1, .., b3, ... b10001, .. bN .. through websocket, I actually want to append each received block data to a target download file, and free the memory of them once they have been written on disk... – ghostplant Jun 10 '16 at 02:58
  • You probably want to lookin to something like [StreamSaver.js](https://github.com/jimmywarting/StreamSaver.js) - not a viable solution since it only works on chrome v52 – Endless Jun 10 '16 at 14:05
  • @Infer-On Appending blob data is not a really viable solution as the blob is kept in memory, What you can do is append chunks to a file in a sandboxed filesystem. But that also only works in Blink – Endless Jun 10 '16 at 14:09

0 Answers0