Search code examples
javascriptnode.jszipadm-zip

Adm Zip - files zipped as folder


I am using adm-zip to zip the local directory and all its nested files and directories.

var AdmZip = require('adm-zip');
var pathToZip = process.env.PUBLIC + '/Demo/Backup.zip';
var zip = new AdmZip();
zip.addLocalFolder("C:\\Users\\Public\\Test\\db");
zip.writeZip(pathToZip);

Problem:

All the files are getting added as folders inside the zip and the actual content is not getting zipped.

Where i am wrong?


Solution

  • There is a bug with the addLocalFolder function in Windows, but there is an easy fix, look at this entry: https://github.com/cthackers/adm-zip/pull/132/files

    Tip: Always check the current state of the library you are working with first. :)