import * as fs from 'fs';
import * as JSZip from 'jszip';
let jszip = new JSZip();
jszip.file("aaa.txt", 'aaaa');
jszip.file("bbb.txt", 'bbbb');
jszip.file("ccc.txt", 'cccc');
jszip.generateNodeStream({ type: 'nodebuffer', streamFiles: true })
.pipe(fs.createWriteStream('out.zip'))
.on('finish', function () {
console.log('out.zip');
fs.readFile('out.zip', function (err, data) {
if (err) throw err;
jszip.loadAsync(data).then(async function (zip) {
console.log(zip);
for(let key in zip.files){
console.log(await jszip.file(key).async('text'));
}
});
});
});
여러개의 파일을 압축하고, 다시 압축 푸는것
jszip 공식 홈페이지
'Develop' 카테고리의 다른 글
perforce ignore (0) | 2018.09.05 |
---|---|
python AES 암호화 (0) | 2018.05.17 |
mac 에서 logcat (0) | 2018.02.22 |
vscode 지금업데이트 안됨 (0) | 2017.09.18 |
aws lambda express.js 세팅기 (0) | 2017.08.23 |