Skip to main content
Module

x/zipjs/index.js>ZipWriter

JavaScript library to zip and unzip files in the browser and Deno supporting multi-core compression, compression streams, Zip64 and encryption.
Go to Latest
class ZipWriter
import { ZipWriter } from "https://deno.land/x/zipjs@v2.6.11/index.js";

Represents a ZipWriter instance used to create a zip file.

Example:

// 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 = blobWriter.getData();

Constructors

new
ZipWriter(writer: Writer<Type> | WritableWriter, options?: ZipWriterConstructorOptions)

Creates the ZipWriter instance

Properties

readonly
optional
hasCorruptedEntries: boolean

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

Methods

add<ReaderType>(
filename: string,
reader: Reader<ReaderType> | ReadableReader | void,
options?: ZipWriterAddDataOptions,
): Promise<Entry>

Adds an entry into the zip file

close(comment: Uint8Array | void, options?: ZipWriterCloseOptions): Promise<Type>

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