Question

Is it possible to set content-disposition to "attachment" for files uploaded via fckeditor ?

Was it helpful?

Solution 2

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);


    }

OTHER TIPS

I don't think so. Only for resources in DMS.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top