Tweakr
    Preparing search index...

    Function downloadFile

    • Triggers a file download in the browser.

      Accepts either a Blob object or a string URL and downloads it with the specified filename.

      Parameters

      • data: string | Blob

        The file data as a Blob or a string URL.

      • filename: string

        The desired name of the downloaded file.

      Returns void

      // Download a text file
      const blob = new Blob(["Hello World"], { type: "text/plain" });
      downloadFile(blob, "hello.txt");

      // Download from a URL
      downloadFile("https://example.com/file.pdf", "file.pdf");

      1.1.0