Module base module

Module zip

zip file compression and decompression module

Instructions:

1
var zip = require('zip');

Static function

isZipFile

Determine if the file is in zip format

1
static Boolean zip.isZipFile(String filename) async;

Call parameters:

  • filename : String, filename

Returns the result:

  • Boolean , returns true if the file is a zip file

open

Open a zip file

1 2 3
static ZipFile zip.open(String path, String mod = "r", Integer compress_type = ZIP_DEFLATED) async;

Call parameters:

  • path : String, file path
  • mod : String, open file mode, "r" means read, "w" means create, "a" means append after zip file
  • compress_type : Integer, compression type, ZIP_STORED stands for no compression, only storage. ZIP_DEFLATED is used by default for compression using the zlib library.

Returns the result:

  • ZipFile , returns a zip file object

Open a zip file

1 2 3
static ZipFile zip.open(Buffer data, String mod = "r", Integer compress_type = ZIP_DEFLATED) async;

Call parameters:

  • data : Buffer , zip file data
  • mod : String, open file mode, "r" means read, "w" means create, "a" means append after zip file
  • compress_type : Integer, compression type, ZIP_STORED stands for no compression, only storage. ZIP_DEFLATED is used by default for compression using the zlib library.

Returns the result:

  • ZipFile , returns a zip file object

Open a zip file

1 2 3
static ZipFile zip.open(SeekableStream strm, String mod = "r", Integer compress_type = ZIP_DEFLATED) async;

Call parameters:

  • strm : SeekableStream , zip file stream
  • mod : String, open file mode, "r" means read, "w" means create, "a" means append after zip file
  • compress_type : Integer, compression type, ZIP_STORED stands for no compression, only storage. ZIP_DEFLATED is used by default for compression using the zlib library.

Returns the result:

  • ZipFile , returns a zip file object

constant

ZIP_STORED

Compression type constant, no compression, storage only

1
const zip.ZIP_STORED = 0;

ZIP_DEFLATED

Compression type constant, you need to rely on the zlib library for compression

1
const zip.ZIP_DEFLATED = 1;