happy-opfs
    Preparing search index...

    Function downloadFile

    • Downloads a file from a URL and saves it to a temporary file. The returned response will contain the temporary file path.

      This API is built on @happy-ts/fetch-t.

      • Supports timeout and onProgress via DownloadRequestInit
      • Supports keepEmptyBody to allow saving empty responses
      • Returns an abortable FetchTask

      Parameters

      • fileUrl: string | URL

        The URL of the file to download.

      • OptionalrequestInit: DownloadRequestInit

        Optional request initialization parameters.

      Returns FetchTask<DownloadFileTempResponse>

      A task that can be aborted and contains the result of the download.

      1.0.4

      // Download to a temporary file
      const task = downloadFile('https://example.com/file.pdf');
      (await task.result)
      .inspect(({ tempFilePath }) => console.log(`File downloaded to: ${ tempFilePath }`));
    • Downloads a file from a URL and saves it to the specified path.

      Parameters

      • fileUrl: string | URL

        The URL of the file to download.

      • filePath: string

        The path where the downloaded file will be saved.

      • OptionalrequestInit: DownloadRequestInit

        Optional request initialization parameters.

      Returns FetchTask<Response>

      A task that can be aborted and contains the result of the download.

      1.0.4

      // Download to a specific path
      const task = downloadFile('https://example.com/file.pdf', '/downloads/file.pdf');
      (await task.result)
      .inspect(() => console.log('File downloaded successfully'));

      // Abort the download
      task.abort();