Skip to main content

Download

This action is used to download any data as a file. We use downloadjs for this functionality

Click to expand

Signature

download(data: any, fileName: string, fileType?: string): Promise

Arguments

Argument NameDescription
dataData or URL that would be downloaded
fileNameName of the file to be downloaded
fileTypeThe mime type of the file to be downloaded

Use cases

  • Downloading a Plain Text

    To download a plain text, the expected data is a string representing the text content to be downloaded.

    download(data: string, fileName: string, fileType?: string): void

Click to expand

  • Downloading an image

    To download an Image, the expected data is the image's URL or Base64 string.

Click to expand

  • Downloading a file

    By supplying the URL of the file to be downloaded, files of different types can be downloaded via the download action.

    For files to be successfully downloaded, their contents must be served over HTTPS to prevent requests from being blocked. To prevent Cross-Origin Resource Sharing (CORS) errors, ensure that the server where the file is fetched from is CORS-enabled and returns the required headers in the response.