lin*_*ina 0 playframework playframework-1.x
我是游戏框架的新手,我想通过以下方式下载文件:
是否可以在游戏框架中做?如果是的话,请给我一些想法。
谢谢
使用播放控制器可以轻松下载文件,如下所示,
public Result downloadFile(){
File fileToDownload = new File("/path/fileToDownload.pdf"):
response().setContentType("application/x-download");
response().setHeader("Content-disposition", "attachment; filename=fileToDownload.pdf");
return ok(fileToDownload);
}
Run Code Online (Sandbox Code Playgroud)
斯卡拉方式
def downloadFile = Action {
Ok.sendFile(
content = new java.io.File("/path/fileToDownload.pdf"),
fileName = _ => "fileToDownload.pdf"
)
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3629 次 |
| 最近记录: |