Function download

  • Several ways of file downloading:

    1. For file formats that some browsers do not recognize. Enter the file URL in the address bar, window.location.href = URL, window.open(URL);
    2. using a tag download attribute (or js create a tag);
    3. browser-recognizable pdf, txt files, back-end compatible with handling attachment;
    4. add token in the header for authenticated download, use XmlHttpRequest to want to backend to launch the request

    Parameters

    • url: string

      link

    • filename: string

      filename

    • Optionaltype: string

      download type 'href','open','download','request'

    Returns void