node-archiver destination folder

1.8k views Asked by At

I'm using node-archiver to zip some files and in the zip file I find the archived files under the directory where was zipped from.

So in the zip file, 'myfile.txt' is under this sort of directory: 'home/ubuntu/some_folder/another_folder/' I want to have the files in the root directory of the zip file.

This is the code I suspect that is in charge with this:

archive.bulk(
   {src: filePaths}
);

Its documentation is here although I don't see how to do it.

Any ideas?

1

There are 1 answers

2
Berio On

Just add expand:true, flatten:true and indicate what name you want to use for destination folder (dest: 'destinationfoldername/')

archive.bulk(
   {src: filePaths, dest:'destinationfoldername/', expand:true, flatten:true}
);

It workerd for me