【发布时间】:2013-03-01 01:15:06
【问题描述】:
我正在开发一个 grails 应用程序,它具有文件共享功能。它将文件上传到服务器并允许用户从服务器下载文件。我为此使用了以下代码:
def file = new java.io.File(filePath)
response.setContentType( "application-xdownload")
response.setHeader("Content-Disposition", "attachment;filename=${fileName}")
response.getOutputStream() << new ByteArrayInputStream(file.getBytes())
此代码适用于小文件,但当文件大小增加时,即 >100MB,它会给我以下错误:
java.lang.OutOfMemoryError: Java heap space
那么,我该怎么做才能让我的应用程序能够下载大文件? 谢谢
【问题讨论】:
标签: file grails groovy download