hi,
i have the following problem.
i have an asset (a pdf file) and i want to download that if the user
clicks on a directlink, but i always get a filenotfoundexception
if i try to generate the fileinputstream-object.
code:
public void downloadFileAction(IRequestCycle cycle) {
try {
HttpServletResponse response =
cycle.getRequestContext().getResponse();
IAsset asset = getAsset("downloadFile");
File file = new File(asset.getResourceLocation().getPath());
System.out.println(file.length());
FileInputStream fileInputStream = new FileInputStream(file);
BufferedInputStream bufferedInputStream = new
BufferedInputStream(fileInputStream);
int size = (int) file.length();
byte[] data = new byte[size];
bufferedInputStream.read(data, 0, size);
bufferedInputStream.close();
response.setContentType("application/pdf");
response.setHeader("Content-disposition",
"inline; filename=" + getCurrentFile().getFileName());
response.setContentLength(size);
ServletOutputStream out = response.getOutputStream();
out.write(data);
response.flushBuffer();
out.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
page file:
...
<context-asset name="downloadFile" path="uploads/test.pdf"/>
...
so does anyone know how to download a file to the user?
thanks for your help!
regards
sebastian
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]