Avena Webapp API - v0.0.1
    Preparing search index...

    Function runAndSaveExport

    • Runs an export and saves it: into writable, chunk by chunk, when the user chose a file, otherwise through a download link once the export completes.

      With a file, run gets a chunk consumer that writes to it; pass that on as downloadExportViaNats's onChunk, so each write finishes before its chunk is acknowledged. The file is closed when the export completes. If the export or a write fails, or the export is cancelled, the file is aborted instead, which discards what was written; a file that was being replaced stays as it was.

      Parameters

      • writable: SaveFileWritable | null

        The chosen file, or null to save through a download link.

      • run: (onChunk?: (data: Uint8Array) => Promise<void>) => Promise<ExportStreamResult>

        Starts the export, passing onChunk on to the download (it is undefined without a file, and the result's Blob is saved instead).

      • saveBlob: (blob: Blob, fileName: string) => void = saveBlobViaLink

        Saves the Blob; saveBlobViaLink unless a test passes one.

      Returns Promise<ExportStreamResult>

      The export result.

      Whatever the export, a write or closing the file throws.