![]() more examples in the wikiįor more detailed information please check out the wiki. writeZip ( /*target file name*/ "/home/me/files.zip" ) //. toBuffer ( ) // or write everything to disk zip. addLocalFile ( "/home/me/some_picture.png" ) // get everything as a buffer var willSendthis = zip. length, content ), "entry comment goes here" ) // add local file zip. extractAllTo ( /*target path*/ "/home/me/zipcontent/", /*overwrite*/ true ) // creating archives var zip = new AdmZip ( ) // add file directly var content = "inner content of the file" zip. extractEntryTo ( /*entry name*/ "some_folder/my_file.txt", /*target path*/ "/home/me/tempfolder", /*maintainEntryPath*/ false, /*overwrite*/ true ) // extracts everything zip. readAsText ( "some_folder/my_file.txt" ) ) // extracts the specified file to the specified location zip. forEach ( function ( zipEntry ) ) // outputs the content of some_folder/my_file.txt console. ![]() getEntries ( ) // an array of ZipEntry records zipEntries. By calling this method we can control which items can be extracted.Var AdmZip = require ( 'adm-zip' ) // reading archives var zip = new AdmZip ( "./my_file.zip" ) var zipEntries = zip. This method can be used to prevent extraction of the current item. preventDefault(): Function - Prevent extracting current entry.There are 48 other projects in the npm registry using zip-lib. Start using zip-lib in your project by running npm i zip-lib. entr圜ount: Number (readonly) - Total number of entries. Latest version: 0.7.3, last published: 2 years ago.entryName: String (readonly) - Entry name.event: Object - Represents an event that an entry is about to be extracted. ![]() OnEntry?: Function (optional) - Called before an item is extracted. If you set symlinkAsFileOnWindows to false and the zip contains symlink, be sure to run the code under the administrator, otherwise an EPERM error will be thrown. ![]() ⚠ WARNING: On Windows, the default security policy allows only administrators to create symbolic links. If false, the symlink in the zip will be extracted as a symlink correctly on Windows, but an EPERM error will be thrown under non-administrators. If true, the symlink in the zip will be extracted as a normal file on Windows. This value is only available on Windows and ignored on other platforms. SymlinkAsFileOnWindows?: Boolean (optional) - Extract symbolic links as files on Windows. Overwrite?: String (optional) - If it is true, the target directory will be deleted before extract. True: add the target of the symbolic link to the zip.įalse: add symbolic link itself to the zip. followSymlinks?: Boolean (optional) - Indicates how to handle when the given path is a symbolic link.If the cancel method is called after the extract is complete, nothing will happen. If the cancel method is called after the archive is complete, nothing will happen. Method: addFolder(folder, )Īdds a folder from the file system at realPath into the zipfile as metadataPath.Ĭancel compression. A valid metadataPath must not start with / or /:\//, and must not contain. metadataPath?: String (optional) - Typically metadataPath would be calculated as path.relative(root, realPath).cancel ( ) API Method: archiveFileĪrchiveFolder(folder, zipFile, )Ĭompress all the contents of the specified folder to zip.Įxtract(zipFile, targetFolder, )Įxtract the zip file to the specified location.Īdds a file from the file system at realPath into the zipfile as metadataPath. addFolder ( "path/to/folder", "new folder" ) // Generate zip file. addFile ( "path/to/file2.txt", "folder/file.txt" ) // Adds a folder from the file system, and naming it `new folder` within the archive zip. addFile ( "path/to/file.txt", "renamedFile.txt" ) zip. Zip ( ) // Adds a file from the file system zip. Const zl = require ( "zip-lib" ) const zip = new zl.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |