Skip to content

How to incrementally append files in different directory levels? #150

Answered by 101arrowz
Sec-ant asked this question in Q&A
Discussion options

You must be logged in to vote

There is a wiki that provides an example of how to make a ZIP file generator in a web browser. It incrementally appends data like you ask, but from a file rather than from generated data. But the concepts are similar: here's how I would do it.

// Zip: full zip archive
// ZipDeflate: zip file using compression
// ZipPassThrough: zip file uncompressed
// AsyncZipDeflate: zip compression offloaded to a separate thread
// EncodeUTF8: text to binary conversion
const { Zip, ZipDeflate, EncodeUTF8, ZipPassThrough } = require('fflate');

const chunks = [];

const zip = new Zip((err, chunk, final) => {
  if (err) throw err;

  // You can also write this to another stream (like a file) rather than …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Sec-ant
Comment options

Answer selected by Sec-ant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants