通过grails页面中的链接下载文件时,以下控制器正在运行。但是,以某种方式下载的文件也保存在我的项目结构web-app中。现在,它正在我的本地主机上运行。因此,当转移到生产时,这将开始在服务器中保存文件。有没有办法允许定期下载到客户端的计算机,但阻止或清除下载到服务器?
File uploadedInBackEndToBeDownloadedFromFrontEnd = fetchTheFileFromBackEnd() // some custom method
response.setHeader("Content-Type", "application/octet-stream;")
response.setHeader("Content-Disposition", " uploadedInBackEndToBeDownloadedFromFrontEnd ; filename=\"${ uploadedInBackEndToBeDownloadedFromFrontEnd .name}\"")
response.setHeader("Content-Length", "$ uploadedInBackEndToBeDownloadedFromFrontEnd .size()}")
response.outputStream << uploadedInBackEndToBeDownloadedFromFrontEnd .getBytes()
非常感谢!!