Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-3058

Filedownload adds the session id to the file name

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 8.5.2
    • 8.0.0
    • ZK Update Engine
    • Security Level: Jimmy
    • Servers: Tomcat/Jetty/(likely others) ... with enabled url-rewriting (enabled by default)
      IE / FF / Safari?
      (Chrome is unaffected)

    • ZK 8.5.2 S1, ZK 8.5.2 S2

      The Filedownload.save method doesn't add the suggested file name to the HTTP header "Content-Disposition".

      Code from zk 3.6.4 (Https.write):

      if (download) {
        String value = "attachment";
        final String flnm = media.getName();
        if (flnm != null && flnm.length() > 0)
          value += ";filename=\"" + URLs.encode(flnm) +'"';
        response.setHeader("Content-Disposition", value);
        //response.setHeader("Content-Transfer-Encoding", "binary");
      }
      

      Code from zk 8.0.0 (Https.write):

      if (download) {
        String value = "attachment";
        
        // Bug ZK-1257: Filedownload.save(media, filename) does not save the media as the specified filename
        StringBuffer temp = request.getRequestURL();
        final String update_uri = (String)request.getSession().getServletContext().getAttribute("org.zkoss.zk.ui.http.update-uri"); //B65-ZK-1619
        String flnm = "";
        if (update_uri != null && temp.toString().contains(update_uri + "/view")) {
          // for Bug ZK-2350, we don't specify the filename when coming with ZK Fileupload, but invoke this directly as Bug ZK-1619
      //	final String saveAs = URLDecoder.decode(temp.substring(temp.lastIndexOf("/")+1), "UTF-8");
      //	flnm = ("".equals(saveAs)) ? media.getName() : saveAs;
        } else
          flnm = media.getName();
        if (flnm != null && flnm.length() > 0)
          value += ";filename=" + encodeFilename(request, flnm);
        if (media.isContentDisposition())
          response.setHeader("Content-Disposition", value);
        //response.setHeader("Content-Transfer-Encoding", "binary");
      }
      

      The 3.6.4 version adds the file name to the HTTP header.

      The 8.0.0 only adds the file name to the HTTP header if the condition update_uri != null && temp.toString().contains(update_uri + "/view") is false. The condition is by default true because the request URL normally contains the string /zkau/view (update_uri + "/view").

            rudyhuang rudyhuang
            famls famls
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 1 day
                1d
                Remaining:
                Time Spent - 5 hours Remaining Estimate - 3 hours
                3h
                Logged:
                Time Spent - 5 hours Remaining Estimate - 3 hours
                5h