Is it possible to set content-disposition to "attachment" for files uploaded via fckeditor ?
Actually I just figure out a work around; adding a servlet filter that alters http header attribute content-disposition
to attachment
and that's it!
here is a the code snippet:
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
StringBuffer fileName = new StringBuffer();
HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse resp = (HttpServletResponse) response;
StringBuffer extension = new StringBuffer(
FilenameUtils.getExtension(req.getRequestURL().toString()));
log.debug("--***-- File extension : " + extension.toString());
if (extension.toString().equalsIgnoreCase("pdf")
|| extension.toString().equalsIgnoreCase(".pdf")) {
fileName.append(FilenameUtils.getBaseName(req.getRequestURL()
.toString()));
log.debug("--***-- PDF file name : " + fileName.toString());
resp.addHeader("Content-Disposition", "attachment; filename="
+ fileName);
}
chain.doFilter(request, resp);
}