node-unzipper icon indicating copy to clipboard operation
node-unzipper copied to clipboard

Open.url and a file filter with a bunch of files

Open karikera opened this issue 5 years ago • 2 comments

I tried to download and unzip a bunch of files with a file filter.

    const archive = await unzipper.Open.file(zipfile);
    for (const file of archive.files)
    {
        if (file.type == 'Directory') continue;
        const filepath = ~~~~
        const exists = fs.existsSync(filepath);
        if (exists) continue;
        files.push(file);
    }
   await kindOfConcurrencyUnzipFunction(files);

file count is over 1000. and unzipper sends the request per file. pretty insane. the web server blocks requests by too many requests.

how can I make it as one request?

karikera avatar Dec 21 '20 07:12 karikera

Can't you just do:

http.get("file-url", (res) => {
    const zip = res.pipe(unzipper.Parse({forceStream: true}));
    for await (const entry of zip) {
        // etc etc

    }
});

warerebel avatar Jan 27 '21 18:01 warerebel

@warerebel It seems better. I wasn't used to piping. thanks.

karikera avatar Jan 27 '21 20:01 karikera