【问题标题】:Magnolia-cms fckeditor: Content-disposition:attachment for uploaded filesMagnolia-cms fckeditor:内容处置:上传文件的附件
【发布时间】:2014-03-03 11:32:51
【问题描述】:

对于通过 fckeditor 上传的文件,是否可以将 content-disposition 设置为“附件”?

【问题讨论】:

    标签: fckeditor content-disposition magnolia


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      其实我只是想办法解决;添加一个servlet过滤器,将http头属性content-disposition更改为attachment,就是这样! 这是sn-p的代码:

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

      【讨论】:

        猜你喜欢
        • 2016-06-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-02-22
        • 1970-01-01
        相关资源
        最近更新 更多