0
메모리에 zip을 생성 할 노드 모듈이 있습니까? (이 zip 파일을 디스크에 저장하지 않으므로)이 생성 된 zip 파일을 다른 서버로 보낼 수 있습니다 (From 기억). 이 작업을 수행하는 가장 좋은 방법은 무엇입니까? Gzip으로 할 경우노드 모듈을 사용하여 메모리에있는 Crete ZIP 파일
var file_system = require('fs');
var archiver = require('archiver');
var dirToCompress = 'directoryToZIP';
module.exports = function (req, res, next) {
var archive = archiver.create('zip', {});
archive.on('error', function (err) {
throw err;
});
var output = file_system.createWriteStream('/testDir/myZip.zip',{flags:'a'});//I don't want this line
output.on('close', function() {
console.log(archive.pointer() + ' total bytes');
console.log('archiver has been finalized and the output file descriptor has closed.');
});
archive.pipe(output);
archive.directory(dirToCompress);
archive.finalize();
};
[archiver] (https://www.npmjs.com/package/archiver)를 사용하고 스트림을 응답으로 파이프하는 것이 좋습니다. 이렇게하면 디스크에 아무 것도 쓸 필요가 없습니다. –
출력 변수는 다른 서버의 api가되어이 zip 파일을 보낼 수 있습니다. – Torreto