@gyng/remote-zip
    Preparing search index...

    Class RemoteZip

    An initialised object representating a remote ZIP archive.

    Best constructed from a RemoteZipPointer.

    import { RemoteZipPointer } from "remote-zip";

    const url = new URL("http://www.example.com/test.zip");
    const remoteZip = await new RemoteZipPointer({ url }).populate();
    Index

    Constructors

    • Parameters

      • __namedParameters: {
            centralDirectoryRecords: CentralDirectoryRecord[];
            contentLength: number;
            credentials: "include" | "omit" | "same-origin";
            endOfCentralDirectory: EndOfCentralDirectory | null;
            method: string;
            url: URL;
        } & Pick<
            RemoteZipRequestOptions,
            "redirect"
            | "signal"
            | "timeoutMs"
            | "requestInit",
        >
        • centralDirectoryRecords: CentralDirectoryRecord[]
        • contentLength: number

          Length of the remote ZIP archive in bytes

        • credentials: "include" | "omit" | "same-origin"

          Passed to fetch when performing a HTTP GET request for the file.

        • endOfCentralDirectory: EndOfCentralDirectory | null
        • method: string

          Passed to fetch when performing a HTTP GET request for the file

        • url: URL

          Passed to fetch when performing a HTTP GET request for the file

      Returns RemoteZip

    Properties

    centralDirectoryRecords: CentralDirectoryRecord[]

    Records representing the files in the remote ZIP archive

    contentLength: number

    Size of the remote ZIP archive in bytes

    credentials: "include" | "omit" | "same-origin"

    Credentials passed to fetch when retrieving files. Defaults to same-origin.

    endOfCentralDirectory: EndOfCentralDirectory | null

    Metadata of the remote ZIP archive

    method: string

    HTTP method used to fetch files from the remote ZIP archive

    redirect?: RequestRedirect

    Redirect mode passed to fetch. Defaults to "follow".

    requestInit?: RequestInit

    Extra RequestInit merged into every fetch.

    signal?: AbortSignal

    Signal that aborts in-flight requests.

    timeoutMs?: number

    Per-request timeout in milliseconds.

    url: URL

    URL of the remote ZIP archive

    Methods

    • Gets a single uncompressed file in the remote ZIP archive.

      Parameters

      • path: string

        Path of the file in the remote ZIP archive

      • OptionaladditionalHeaders: Headers

        Additional headers, if any, to be passed to the fetch request

      • Optionaloptions: EntryDecodeOptions

        Per-call options for RemoteZip.fetch / RemoteZip.fetchStream.

        • OptionalmaxUncompressedSize?: number

          If set, decompression aborts and throws once output would exceed this many bytes.

        • Optionalpassword?: string

          Password for an encrypted entry (traditional ZipCrypto or WinZip AES).

        • Optionalsignal?: AbortSignal

          Aborts this request (in addition to any instance-level signal).

        • OptionaltimeoutMs?: number

          Per-request timeout in milliseconds.

        • OptionalverifyCrc?: boolean

          If set, verify the decompressed output against the entry's CRC-32.

      Returns Promise<Uint8Array<ArrayBufferLike>>

      Inflated (uncompressed) bytes of the requested file

      RemoteZipError if it fails to parse, fetch, or exceeds limits

    • Like fetch, but returns a ReadableStream of the uncompressed bytes so large entries can be processed incrementally without buffering the whole file. maxUncompressedSize is enforced mid-stream (the stream errors with a RemoteZipError once exceeded).

      const stream = await remoteZip.fetchStream("big.bin");
      for await (const chunk of stream) {
      // process each chunk
      }

      Parameters

      Returns Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>

    • Get a formatted file listing of the remote ZIP archive.

      Returns RemoteZipFile[]

      List of files in the remote ZIP archive.

      import { RemoteZipPointer } from "remote-zip";

      const url = new URL("http://www.example.com/test.zip");
      const remoteZip = await new RemoteZipPointer({ url }).populate();
      const files = remoteZip.files();
      // files = [{ attributes: 1107099648, filename: "text.txt", modified: "2021-06-17T12:28:02", size: 14 }]