pouchdb-community / pouchdb-replication-stream

Replicate PouchDB/CouchDB databases with Node.js-style streams
Apache License 2.0
189 stars 58 forks source link

How do you dump db to a download stream with streamsaver in Browser? #82

Open dreamofi opened 4 years ago

dreamofi commented 4 years ago

Hello,

I am trying to dump a db directly to a file for download using streamsaver in the browser (I use React), however, it does not work and the error is "dest.on is not a function". I guess it is because I use web-stream ponyfill which does not have the on() method on the stream.

Currently, I am dumping the db to a string with memorystream, and then create a blob from the string and stream it to streamsaver's writableStream. I think as the db can be large, the memory needed to store the string will be significant.

So, do you guys know of a way/lib to dump a db to a file directly in a browser (where fs.createWriteStream is unavailable) without memorystream?