How to download a file with Play Framework 2.0

前端 未结 3 1532
情深已故
情深已故 2021-02-02 13:59

I\'m using Play Framework 2.0.3 to create an application which delivers Excel files that should be downloadable by the user.

 response().setContentType(\"applic         


        
3条回答
  •  无人及你
    2021-02-02 14:13

    Play's action can return a File:

    response().setContentType("application/x-download");  
    response().setHeader("Content-disposition","attachment; filename=tradeLogTest.xlsx"); 
    return ok(new File("/absolute/path/to/tradeLogTest.xlsx"));
    

    Here's an API for Results

提交回复
热议问题