«   2018/10   »
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Archives
Today
222
Total
1,167,381
안정적인 DNS서비스 DNSEver
관리 메뉴

Blue Breeze

node.js zlib compress uncompress 본문

Language/Node.js

node.js zlib compress uncompress

푸른바람 C/H 2018.01.10 13:26

file gzip

const zlib = require('zlib');

const gzip = zlib.createGzip();
const fs = require('fs');
const inp = fs.createReadStream('input.txt');
const out = fs.createWriteStream('input.txt.gz');

inp.pipe(gzip).pipe(out);

string flate

const input = '.................................';
zlib.deflate(input, (err, buffer) => {
  if (!err) {
    console.log(buffer.toString('base64'));
  } else {
    // handle error
  }
});

const buffer = Buffer.from('eJzT0yMAAGTvBe8=', 'base64');
zlib.unzip(buffer, (err, buffer) => {
  if (!err) {
    console.log(buffer.toString());
  } else {
    // handle error
  }
});


'Language > Node.js' 카테고리의 다른 글

2진수 채우기 zerofill  (0) 2018.01.12
node.js Buffer  (0) 2018.01.11
node.js zlib compress uncompress  (0) 2018.01.10
Pm2 log dateformat  (0) 2017.06.16
pm2 JSON(설정)으로 실행  (0) 2017.03.13
pm2 1.1.3 to 2.1.5 upgrade  (0) 2016.11.24
0 Comments
댓글쓰기 폼