2017-08-31 100 views
0

我有Angular前端和Spring Boot後端的應用程序。在前端我有HTML按鈕,通過我想下載文件。 Proble的是,它表現不同的遠程服務器上,並在localhost:Spring Boot&Angular 2:從服務器下載文件

  1. 本地主機 - 按下按鈕文件後,下載

    <button download="output.txt" href="http://localhost:8080/output/output.txt"> Download </button> 
    
  2. 遠程服務器:按下按鈕後一無所獲發生

    <button download="output.txt" href="https://www.bla.com/output/output.txt"> Download </button> 
    

但是,如果我的網址https://www.bla.com/output/output.txt複製到瀏覽器中的文件被下載。

回答

0

的解決辦法是使用:

<a download="output.txt" href="https://www.bla.com/output/output.txt">Download</a>