@rendley/sdk - v1.14.0
    Preparing search index...

    Class OutputChunkHelper

    Index

    Constructors

    Properties

    chunks: OutputChunkFileDesc[] = []
    extension: string
    mimeType: string

    Methods

    • Prompts the user for a save location and writes all output chunks to the selected file.

      Uses the File System Access API (showSaveFilePicker) and writes each chunk sequentially.

      Parameters

      • fileName: string

        Suggested filename shown in the save dialog.

      • progressCallback: null | ((progress: number) => void) = null

        Optional callback function to receive progress updates. range [0 - 1]

      • bufferSize: number = ...

        Reserved chunk step size in bytes. Defaults to 100 * 1024 * 1024 (100 MB).

      Returns Promise<boolean>

      A promise that resolves to true when all chunks are written successfully, otherwise false.

    • Checks whether the browser supports the File System Access save picker API.

      Returns boolean

      true when window.showSaveFilePicker is available; otherwise false.

    • Reads the specified chunk and returns it as a Blob.

      Parameters

      • chunkId: number

        Identifier (index) of the chunk to read.

      Returns Promise<null | Blob>

      A Promise that resolves to a Blob containing the chunk's data, or null if the chunk is missing or unreadable.

      Not recommended because it will double the memory usage!

      If the chunk with the given id exists, this method attempts to read its bytes via readChunkBytes and constructs a Blob using the instance's mimeType. If the chunk does not exist or the bytes cannot be read, the promise resolves to null.

      Propagates any error thrown by readChunkBytes.

    • Reads the raw bytes for a chunk by its numeric identifier.

      Attempts to read the chunk as Uint8Array from the chunkId. If the chunk exists and the read succeeds, the promise resolves to a Uint8Array containing the file bytes. If the chunk is missing or an error occurs during reading, the error is logged and the promise resolves to null.

      Parameters

      • chunkId: number

        The numeric identifier (index) of the chunk to read.

      Returns Promise<null | Uint8Array<ArrayBufferLike>>

      A promise that resolves to the chunk's bytes as a Uint8Array, or null if the chunk does not exist or could not be read.

    • Creates an object URL for the specified chunk if it exists.

      Parameters

      • chunkId: number

        The identifier (index) of the chunk to read.

      Returns Promise<null | string>

      A Promise that resolves to an object URL string for the chunk Blob, or null if the chunk does not exist or could not be read.

      Not recommended because it will double the memory usage!

      Attempts to read the chunk as a Blob (via readChunkAsBlob) and, if a Blob is obtained, returns a URL created with URL.createObjectURL(blob). If the chunk is not present or cannot be read, the promise resolves to null.

      Note: callers are responsible for revoking the returned URL with URL.revokeObjectURL when it is no longer needed to avoid memory leaks.

    • Reads merged chunks and converts them to a Blob object.

      Returns Promise<null | Blob>

      A promise that resolves to a Blob if chunks are successfully read and merged, or null if no bytes are available.

      Not recommended because it will double the memory usage!

    • Reads and merges all chunks into a single Uint8Array.

      Returns Promise<null | Uint8Array<ArrayBufferLike>>

      A promise that resolves to a merged Uint8Array containing all chunk data, or null if an error occurs during reading or merging.

      Does not throw, but logs errors at ERROR level if chunk reading or merging fails.

      const mergedData = await helper.readMergedChunksAsBytes();
      if (mergedData) {
      // Process merged chunk data
      }
    • Reads merged chunks and returns them as a URL object reference.

      Returns Promise<null | string>

      A promise that resolves to a blob URL string, or null if no blob data is available.

      Not recommended because it will double the memory usage! Don't forget to revoke the URL after usage!

    • Returns Promise<void>

    • Parameters

      • chunkId: number

      Returns Promise<void>