Hiển thị các bài đăng có nhãn zip stdout. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn zip stdout. Hiển thị tất cả bài đăng

Crete ZIP file in memory

Source: https://medium.com/@harrietty/zipping-and-unzipping-files-with-nodejs-375d2750c5e4

https://stackoverflow.com/questions/42992604/crete-zip-file-in-memory-using-any-node-module

If GZip will do, you can use the built-in zlib module and not even have to load an external module.
const zlib = require('zlib');
const gzip = zlib.createGzip();
// If you have an inputStream and an outputStream:

inputStream.pipe(gzip).pipe(outputStream);
For Zip and not GZip, you can check out archiver or zip-stream.

All the unzipping for all the files


const fs = require('fs');
const zlib = require('zlib');
const directoryFiles = fs.readdirSync('./data');
directoryFiles.forEach(filename => {
const fileContents = fs.createReadStream(`./data/${filename}`);
const writeStream = fs.createWriteStream(`./data/${filename.slice(0, -3)}`);
const unzip = zlib.createGunzip();
fileContents.pipe(unzip).pipe(writeStream);
});

anti-pattern là gì

  Trong công nghệ và lập trình, Anti-pattern (mẫu phản diện) là những giải pháp bề ngoài có vẻ hiệu quả để giải quyết một vấn đề phổ biến, ...