/*--- title: Zip and unzip group: Files summary: ziplib: pack a folder, inspect the archive and extract it again. ---*/ requirelib("filelib"); requirelib("ziplib"); ziplib.createZipFile("user:/Documents", "tmp:/documents.zip"); console.log("Valid zip: " + ziplib.isValidZipFile("tmp:/documents.zip")); console.log("Type: " + ziplib.getCompressFileType("tmp:/documents.zip")); // listZipFileContents returns the archive as a tree (a JSON string). var tree = JSON.parse(ziplib.listZipFileContents("tmp:/documents.zip")); // Pack two files into a .tar.gz; the type follows the extension. ziplib.createAnyZipFile(["user:/Documents/notes.md", "user:/Documents/scores.csv"], "tmp:/two.tar.gz"); ziplib.extractZipFile("tmp:/documents.zip", "tmp:/unzipped"); sendJSONResp({ archive: filelib.filesize("tmp:/documents.zip") + " bytes", topLevel: Object.keys(tree.children || {}), extracted: filelib.walk("tmp:/unzipped", "file"), tarGz: filelib.filesize("tmp:/two.tar.gz") + " bytes" });