Magnolia-cms fckeditor:Content-disposition:上传文件的附件

时间:2014-03-03 11:32:52

标签: fckeditor content-disposition magnolia

是否可以将内容处理设置为通过fckeditor上传的文件的“附件”?

2 个答案:

答案 0 :(得分:0)

我不这么认为。仅适用于DMS中的资源。

答案 1 :(得分:0)

其实我只是找出一个解决方法;添加一个servlet过滤器,将http标头属性content-disposition改为attachment,就是这样! 这是一段代码片段:

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


    }