Optionalbufferedtrue to write entry data in a buffer before appending it to the zip file.
bufferedWrite is automatically set to true when compressing more than one entry in parallel.
OptionalcommentThe comment of the entry.
It is a string, unlike the global comment passed to ZipWriter#close, because the encoding of the comment of an entry is recorded in the header by the general purpose bit 11 (see Appendix D - Language Encoding (EFS)), set by ZipWriterConstructorOptions#useUnicodeFileNames. Passing raw bytes here throws ERR_INVALID_ENTRY_COMMENT_TYPE instead of writing their textual representation.
OptionalcompressionThe compression method (e.g. 8 for DEFLATE, 0 for STORE).
Optionalcrc32The CRC-32 checksum of the content. This option is ignored if the ZipWriterConstructorOptions#passThrough option is not set to true.
When the entry is AES-encrypted (see ZipWriterConstructorOptions#encrypted), setting this option marks the entry as AE-1 and stores the checksum in the entry headers, e.g. when copying an AE-1 entry read with the ZipReaderOptions#passThrough option. Otherwise, the entry is marked as AE-2 and the checksum fields are set to 0.
OptionalcreateAn async factory function that returns a TransformStream-like object ({ writable, readable }) used as a temporary buffer when entries are written in parallel.
When provided, this replaces the default in-memory TransformStream buffer, allowing data to be stored externally (e.g. filesystem, OPFS, network).
The writable side receives compressed entry data. The readable side is consumed when the entry is replayed into the final zip stream.
The optional dispose method is called once the entry has been processed (on success, error, or abort) so a resource-backed buffer can release its resource.
See createOPFSTempStream for a ready-made OPFS-backed implementation, createSyncAccessHandleTempStream for a faster worker-only variant, and createBlobTempStream for a Blob-backed one.
The readable side is consumed only once the writable side has been closed, since the local
header written before it holds the size and the CRC-32 of the entry. The object must therefore be able to
hold a whole entry, either by buffering it like the default
new TransformStream(undefined, undefined, { highWaterMark: Infinity }) does, or by draining it like the
three implementations above do. A factory returning new TransformStream() deadlocks instead, its default
queuing strategy holding a single chunk.
OptionalcreationThe creation date.
This option is ignored if the ZipWriterConstructorOptions#extendedTimestamp option is set to false.
Unlike ZipWriterConstructorOptions#lastModDate, it has no default: the date is written only when the option is set, so that the entries do not carry a meaningless creation time.
Optionaldatatrue to add a data descriptor.
When set to false, the ZipWriterConstructorOptions#bufferedWrite option will automatically be
set to true. It will be automatically set to false when it is undefined and the
ZipWriterConstructorOptions#bufferedWrite option is set to true, or when the entry is a folder
or an empty entry stored without compression or encryption, since the header can then carry the sizes and
the CRC-32 directly. It will be automatically set to true when the
ZipWriterConstructorOptions#zipCrypto option is set to true. Otherwise, the default value is true.
Optionaldatatrue to add the signature of the data descriptor.
Optionaldirectorytrue if the entry is a directory.
Optionalencryptedtrue to write encrypted data when passThrough is set to true.
OptionalencryptionThe encryption strength (AES):
Optionalexecutabletrue if the entry is an executable file.
Optionalextendedtrue to store extended timestamp extra fields.
When set to false, the maximum last modification date cannot exceed December 31, 2107 and the maximum accuracy is 2 seconds, dates being truncated to the whole second and odd seconds rounded up to the next even second.
OptionalexternalThe external file attribute.
Use ZipWriterConstructorOptions#externalFileAttributes instead.
OptionalexternalThe external file attribute.
When set explicitly, the value is written verbatim (including 0), unless unixMode, setuid, setgid
or sticky is also set, in which case these options override the upper 16 bits while the lower 16 bits
are preserved. When omitted, the value is derived from the other options (e.g. the MS-DOS directory
attribute for folder entries, Unix default permissions when msDosCompatible is false).
OptionalextraThe extra field of the entry, written in the local file header and the central directory.
OptionalgidThe Unix group id to write in the Unix extra field or as part of the external attributes.
OptionalinternalThe internal file attribute.
Use ZipWriterConstructorOptions#internalFileAttributes instead.
OptionalinternalThe internal file attribute.
Optionalkeeptrue to keep the order of the entry physically in the zip file.
When set to true, the use of web workers will be improved.
OptionallastThe last access date.
This option is ignored if the ZipWriterConstructorOptions#extendedTimestamp option is set to false.
Unlike ZipWriterConstructorOptions#lastModDate, it has no default: the date is written only when the option is set, so that the entries do not carry a meaningless access time.
OptionallastThe last modification date.
This option and the two below must be Date instances: a timestamp expressed in milliseconds, e.g.
File#lastModified, and an invalid Date are both rejected with ERR_INVALID_DATE. An
invalid Date used to be written as an entry carrying no timestamp at all.
OptionallevelThe level of compression.
The minimum value is 0 and means that no compression is applied. The maximum value is 9.
The native API CompressionStream does not support compression levels. Any value other than 6,
its de facto level, disables useCompressionStream and compresses the data with the embedded
implementation instead. Note that the compressed data produced at a given level can still vary
between platforms. Set useCompressionStream to false to get deterministic output across
platforms.
OptionallocalThe extra field of the entry written only in the local file header.
OptionalmsdosWhen provided, MS-DOS attribute flags (boolean object) to write into external file attributes low byte.
See ZipWriterConstructorOptions#msdosAttributesRaw for the platform this option selects and for the Unix metadata it leaves out of the entry.
OptionalmsdosWhen provided, the low 8-bit MS-DOS attributes to write into external file attributes. Must be an integer between 0 and 255.
Setting this option or ZipWriterConstructorOptions#msdosAttributes selects the MS-DOS platform for
the entry exactly as ZipWriterConstructorOptions#msDosCompatible does, and overrides that option
when it is explicitly set to false. EntryMetaData#versionMadeBy then loses its Unix upper byte
and no Unix mode is written, so the 0o100644 of a file entry and the 0o040755 of a folder entry are
lost. What counts is that the option is provided, not its value: 0 and {} trigger it too.
Setting any Unix metadata option, i.e. ZipWriterConstructorOptions#uid, ZipWriterConstructorOptions#gid, ZipWriterConstructorOptions#unixMode, ZipWriterConstructorOptions#unixExtraFieldType or ZipWriterAddDataOptions#executable, takes precedence and keeps the Unix attributes, with the MS-DOS attributes written into the low byte. ZipWriterConstructorOptions#externalFileAttributes is preserved as well, although the entry still declares the MS-DOS platform.
Optionalmstrue to write EntryMetaData#externalFileAttributes in MS-DOS format for folder entries.
It also selects the MS-DOS platform for ZipWriterConstructorOptions#versionMadeBy and leaves the Unix
attributes out of the entries. Setting any Unix metadata option, e.g.
ZipWriterConstructorOptions#unixMode or ZipWriterAddDataOptions#executable, turns it back off, and setting
ZipWriterConstructorOptions#msdosAttributesRaw or ZipWriterConstructorOptions#msdosAttributes
turns it on, overriding an explicit false.
Optionalntfstrue to always store the NTFS extra field, false to never store it.
By default, the NTFS extra field is stored only when it preserves information the extended timestamp extra field cannot represent: a last modification date outside its supported range, or explicit ZipWriterConstructorOptions#lastAccessDate or ZipWriterConstructorOptions#creationDate values.
This option is ignored if the ZipWriterConstructorOptions#extendedTimestamp option is set to false.
OptionaloffsetThe offset of the first entry in the zip file.
Optionalpasstrue to write the data as-is without compressing it and without crypting it.
The data is never compressed, so the ZipWriterConstructorOptions#level option does not apply and is
ignored. The ZipWriterAddDataOptions#compressionMethod option selects no codec either, it declares
how the data is already compressed and is written as-is in the entry headers. It must be set, otherwise an
ERR_UNDEFINED_COMPRESSION_METHOD error is thrown. The entries with no content, e.g. the
directories, ignore this option entirely. Setting the ZipWriterConstructorOptions#password or the
ZipWriterConstructorOptions#rawPassword option throws an
ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH error, unless the
ZipWriterConstructorOptions#encrypted option is set to true to declare that the data is already
encrypted. In that case the password encrypts the other entries only, and the data written as-is keeps the
password it was encrypted with, which is not verified.
OptionalpasswordThe password used to encrypt the content of the entry.
When a password is set and the ZipWriterConstructorOptions#zipCrypto option is not set to true, the
entry is encrypted in AES AE-2 format: the CRC-32 checksum of the content is stored as 0 so that the zip
file reveals no information about the encrypted content. A stored checksum would allow an attacker to verify
guessed content without knowing the password. The integrity of the data is guaranteed by the authentication
code instead.
Optionalpreventtrue to prevent closing of WritableWriter#writable.
OptionalrawThe password used to encrypt the content of the entry (raw).
Optionalsetgidtrue to set the setgid bit when writing the Unix mode.
Optionalsetuidtrue to set the setuid bit when writing the Unix mode.
OptionalsignalThe AbortSignal instance used to cancel the compression.
OptionalsignatureThe signature (CRC32 checksum) of the content. This option is ignored if the ZipWriterConstructorOptions#passThrough option is not set to true.
Use ZipWriterAddDataOptions#crc32 instead.
Optionalstickytrue to set the sticky bit when writing the Unix mode.
Optionalsupportfalse to never write disk numbers in zip64 data.
Optionaltransfertrue to transfer stream ownership to web workers.
OptionaluidThe Unix owner id to write in the Unix extra field or as part of the external attributes.
OptionaluncompressedThe uncompressed size of the entry. This option is ignored if the ZipWriterConstructorOptions#passThrough option is not set to true.
OptionalunixWhich Unix extra field format to write when creating entries that include Unix metadata.
When ZipFS exports imported entries, their uid/gid are re-emitted as "infozip" regardless of the field type found in the imported zip file, unless this option is set explicitly.
OptionalunixThe Unix mode (st_mode bits) to use when writing external attributes.
The value includes the Unix file type, so it is also how a symbolic link is written: pass
0o120777 and use the path of the link target as the content of the entry. Extractors that
support symbolic links, e.g. Info-ZIP unzip, then restore the entry as a link.
A folder entry is always written with S_IFDIR (0o040000), replacing any file type carried by the
value, so the same mode can be set once on the writer and reused for every entry. Any other entry keeps
the file type it is given, and is written with S_IFREG (0o100000) when the value carries none. Set
ZipWriterConstructorOptions#externalFileAttributes instead to write a mode with no
file type.
Optionalusdztrueto produce zip files compatible with the USDZ specification: the data of the entries is aligned on 64-byte
boundaries and stored uncompressed unless the ZipWriterConstructorOptions#level or
ZipWriterAddDataOptions#compressionMethod options are set explicitly. Setting the
ZipWriterConstructorOptions#password option throws an ERR_UNSUPPORTED_ENCRYPTION_USDZ error.
Optionalusetrue to use the native API CompressionStream/DecompressionStream to compress/decompress data.
When compressing, the native API is only used when level is undefined or equal to 6, see ZipWriterConstructorOptions#level.
Optionalusetrue to mark the file names as UTF-8 setting the general purpose bit 11 in the header (see Appendix D -
Language Encoding (EFS)), false to mark the names as compliant with the original IBM Code Page 437.
Note that this does not ensure that the file names are in the correct encoding.
Optionalusetrue to use web workers to compress/decompress data in non-blocking background processes.
OptionalversionThe "Version" field.
OptionalversionThe "Version made by" field, whose upper byte is the platform and lower byte the version of the specification.
The platform is not taken from the value passed here. It is forced to Unix (3) when the entry carries Unix
metadata, i.e. when ZipWriterConstructorOptions#uid, ZipWriterConstructorOptions#gid,
ZipWriterConstructorOptions#unixMode or ZipWriterConstructorOptions#unixExtraFieldType is set,
since Unix mode bits stored under another platform are ignored by the extractors. It is forced to MS-DOS (0)
when ZipWriterConstructorOptions#msdosAttributes or
ZipWriterConstructorOptions#msdosAttributesRaw is set. Only the lower byte of the value survives in
both cases.
768, i.e. 3 << 8, or 20 when ZipWriterConstructorOptions#msDosCompatible is set to true
Optionalzip64true to use Zip64 to store the entry.
zip64 is automatically set to true when necessary (e.g. compressed data larger than 4GB or with unknown size).
Optionalziptrue to use the ZipCrypto algorithm to encrypt the content of the entry. Setting it to true will also
set the ZipWriterConstructorOptions#dataDescriptor to true.
It is not recommended to set zipCrypto to true because the ZipCrypto encryption can be easily broken.
OptionalencodeThe function called for encoding the filename and the comment of the entry.
The text to encode.
The type of the encoded text, "filename" or "comment".
The encoded text or undefined if the text should be encoded by zip.js.
OptionalonendThe function called when ending compression/decompression.
The total number of bytes (computed).
An empty promise or undefined.
OptionalonprogressThe function called during compression/decompression.
The current progress in bytes.
The total number of bytes.
An empty promise or undefined.
OptionalonstartThe function called when starting compression/decompression.
The total number of bytes.
An empty promise or undefined.
Represents the options passed to ZipWriter#add.