Closed atodhruv closed 5 years ago
Sorry for my late reply. I think this is not a issue of this library, but you here is a sample code:
var fs = require('fs');
var archiver = require('archiver');
var passThrough = require('stream').PassThrough();
archiver.registerFormat('zip-encryptable', require('archiver-zip-encryptable'));
var archive = archiver('zip-encryptable', {
zlib: { level: 9 },
forceLocalTime: true,
password: 'test'
});
archive.pipe(passThrough);
archive.append(Buffer.from('Hello World'), { name: 'test.txt' });
var zip = Buffer.alloc(0);
passThrough.on('readable', function() {
while (data = this.read()) {
zip = Buffer.concat([zip, data], zip.length + data.length);
}
});
archive.finalize()
.then(function() {
passThrough.end();
// You can get zip as Buffer
console.log(zip.length);
});
HelpNeeded How can I get buffer of zip instead of store file in local drive.
Thanks in advance