I want to create a zip
file and new folder
in it.
I created a zip file but couldn't create folders.
Here is my node.js
code;
var archiver = require('archiver');
var zip = archiver('zip');
for(var i=0; i < files.length; i++){
zip.append(new Buffer(files[i].data.buffer), { name: files[i].name } );
}
For example I want to create folder as /first/second
and add file in it.
.zip
first(folder)
second(folder)
file
How can I do it?
Actually, I just realize that it was quite simple by editing the name field in the following line;
zip.append(new Buffer(files[i].data.buffer), { name: files[i].name } );
as
zip.append(new Buffer(files[i].data.buffer), { name: "/folderName/" + files[i].name } );
You can replace /folderName/
with any filename that you want to create.