In my gsp view, I have this code :
<g:each in="${fileResourceInstanceList}" status="i" var="fileResourceInstance">
<tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
<td>${fileResourceInstance.decodeURL()}</td>
<td><a href="${createLinkTo( dir:"/upload_data/datasets/ds"+signalDataInstance.datasetID , file: fileResourceInstance.decodeURL(), absolute:true )}" target="_new">view</a></td>
<td><g:link action="deleteFile" id="${fileResourceInstance.replace('.','###')}" params="[rs:signalDataInstance.datasetID]" onclick="return confirm('Are you sure?');"> delete </g:link></td>
</tr>
</g:each>
I would like to download my csv files, and not read my csv files in my browser !
How to force download ?
Here code part in my controller :
def f = new File( "${linkDir}".toString() )
if( f.exists() ){
f.eachFile(){ file->
if( !file.isDirectory() )
fileResourceInstanceList.add( file.name )
}
}
Where to add this part in my code to force download ? :
response.setHeader("Content-disposition", "attachment; filename=" + file.name + ".csv");
render(contentType: "text/csv", text: file.name.toString());