11/2/2023 0 Comments Npm archiver unzip zip![]() all operations are non-blocking, no sync i/o. Features: it never loads entire archive into memory, everything is read by chunks. You can check if format already exists before to register a new one with isRegisteredFormat. node.js library for reading and extraction of ZIP archives. You can register additional formats with registerFormat. finalize ( ) FormatsĪrchiver ships with out of the box support for TAR and ZIP archives. createWriteStream ( _dirname + '/example.zip' ) const archive = archiver ( 'zip', ) // finalize the archive (ie we are done appending files but streams have to finish yet) // 'close', 'end' or 'finish' may be fired right after calling this method so register to them beforehand archive. By calling this method we can control which items can be extracted.// require modules const fs = require ( 'fs' ) const archiver = require ( 'archiver' ) // create a file to stream archive data to. This method can be used to prevent extraction of the current item. preventDefault(): Function - Prevent extracting current entry.entr圜ount: Number (readonly) - Total number of entries.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. 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. unzip - npm search 449 packages found 1 2 3 23 Sort Packages Optimal Popularity Quality Maintenance unzip exact match Unzip cross-platform streaming API compatible with fstream and fs.ReadStream zip unzip zlib uncompress archive stream extract evanoxfeld published 0.1. Zip ( ) // Adds a file from the file system zip. Latest version: 0.7.3, last published: 2 years ago. 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 |