jimmywarting / StreamSaver.js

StreamSaver writes stream to the filesystem directly asynchronous
https://jimmywarting.github.io/StreamSaver.js/example.html
MIT License
3.95k stars 413 forks source link

Streamwriter is slow under Chrome/Chromium browser #303

Closed morula closed 1 year ago

morula commented 1 year ago

Compared to Firefox, writing a large file under Chrome is about 30 times slower (Firefox 992KB/s, Chrome 38.4KB/s).

I can also reproduce a similar result with the StreamerSave example "https://jimmywarting.github.io/StreamSaver.js/examples/torrent.html".

const writeStream = createWriteStream('test.zip');
const writer = writeStream.getWriter();

jszip
  .generateInternalStream({type: "blob"})
  .on('data', function (data, metadata) {
    writer.write(data);
    //importedSaveAs(data, zipName + '.crypt.ziop');
    console.log(metadata)
    })
  .on('error', function (e) {
    writer.abort(e);
    })
  .on('end', function () {
    writer.close();
    })
  .resume();
jimmywarting commented 1 year ago

It could also be b/c of the zip library you use...

maybe try out my own streaming zip library https://github.com/jimmywarting/StreamSaver.js/blob/master/examples/zip-stream.js got an example here: https://github.com/jimmywarting/StreamSaver.js/blob/master/examples/saving-multiple-files.html

morula commented 1 year ago

It could also be b/c of the zip library you use...

maybe try out my own streaming zip library https://github.com/jimmywarting/StreamSaver.js/blob/master/examples/zip-stream.js got an example here: https://github.com/jimmywarting/StreamSaver.js/blob/master/examples/saving-multiple-files.html

Thank you very much. That works.

Do you have another corresponding ZIP solution with encryption or a hint?

jimmywarting commented 1 year ago

sry, don't have any encryption solution

morula commented 1 year ago

Solution with the proposed streaming zip library works