How can I provide a download of a remote file? The file can be accessed via SMB (jcifs). I can read the properties of the files. But how to send it to the users browser?
This does not work:
render(contentType: 'application/zip',file: new File(FullPath), fileName: domainInstance.getFilename())
Where full path is like smb://user:pass@server.domain.com/root/Files/Dowanload.zip
Accessing the file via works:
SmbFile smbFile = new SmbFile(FullPath ))
Try something like this in your controller:
SmbFile smbFile = new SmbFile(FullPath )//,auth);
if (smbFile.exists()) {
response.setContentType("application/octet-stream")
response.setHeader("Content-disposition", "filename=${domainInstance.getFilename()}")
response.setContentLength(Long.valueOf(smbFile.length()).intValue())
response.outputStream << smbFile.getInputStream()
response.outputStream.flush()
return
}
It works fine in latest Grails 2.4.4!