@zip.js/zip.js
    Preparing search index...

    Class ZipWriter<Type>

    Represents an instance used to create a zip file.

    Here is an example showing how to create a zip file containing a compressed text file:

    // use a BlobWriter to store with a ZipWriter the zip into a Blob object
    const blobWriter = new zip.BlobWriter("application/zip");
    const writer = new zip.ZipWriter(blobWriter);

    // use a TextReader to read the String to add
    await writer.add("filename.txt", new zip.TextReader("test!"));

    // close the ZipReader
    await writer.close();

    // get the zip file as a Blob
    const blob = await blobWriter.getData();

    Type Parameters

    • Type
    Index
    hasCorruptedEntries?: boolean

    true if the zip contains at least one entry that has been partially written.

    • Adds an entry into the zip file

      Type Parameters

      • ReaderType

      Parameters

      • filename: string

        The filename of the entry. Paths must use forward slashes ("/") as separator, as required by section 4.4.17.1 of the zip specification. The value is stored as-is; in particular, Windows path separators ("\") are not converted and become part of the filename, which is interpreted inconsistently by zip tools.

      • Optionalreader:
            | ReadableStream<any>
            | ReadableStream<any>[]
            | ReadableReader
            | Reader<unknown>[]
            | ReadableReader[]
            | Reader<ReaderType>

        The Reader instance used to read the content of the entry.

      • Optionaloptions: ZipWriterAddDataOptions

        The options.

      Returns Promise<EntryMetaData>

      A promise resolving to an EntryMetaData instance.

    • Writes the entries directory, writes the global comment, and returns the content of the zip file

      Parameters

      • Optionalcomment: Uint8Array<ArrayBufferLike>

        The global comment of the zip file.

      • Optionaloptions: ZipWriterCloseOptions

        The options.

      Returns Promise<Type>

      The content of the zip file.

    • Adds an existing zip file at the beginning of the current zip. This method cannot be called after the first call to ZipWriter#add.

      Type Parameters

      • ReaderType

      Parameters

      Returns Promise<void>

      A promise resolving when the zip file has been added.

    • Removes an entry from the central directory that will be written for the zip file. The entry data itself cannot be removed because it has already been streamed to the output.

      Parameters

      • entry: string | Entry

        The entry to remove. This can be an Entry instance or the filename of the entry.

      Returns boolean

      true if the entry has been removed, false otherwise.