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);
});

Không có nhận xét nào:

StaticImage

  import React , { useEffect , useRef } from "react" import { StaticImage } from "gatsby-plugin-image" impor...