@tremendous/help
    Preparing search index...

    Function downloadFile

    • Downloads a file from the given URL and saves it with the specified filename.

      Parameters

      • requestUrl: string

        The URL to request the file from.

      • Optionalfilename: string

        The filename to save the file as. If not provided, it tries to use the filename from the content-disposition header or defaults to "missing_filename".

      • OptionalonError: (e: Event, status: number, responseText?: string) => void

        Callback function to handle errors during the request. The third parameter contains the response text if available.

      • OptionalonLoaded: () => void

        Callback function to handle successful download completion.

      Returns void

      downloadFile("https://example.com/file.pdf", "downloaded_file.pdf");
      
      downloadFile("https://example.com/file.pdf", undefined, (e, status) => {
      console.error(`Failed to download file: ${status}`, e);
      });