Pdf export - wrong content type.

XMLWordPrintable

      For all types of download content always have "application/x-download" content type in header.

      For PDF should be "application/pdf".

      The easiest way to fix is to add parameter to download url in ExportPageAction:

      • is:
            private String prepareDownloadPath(String path) throws IOException
            {
                String homeDir = new File(getBootstrapManager().getConfluenceHome()).getCanonicalPath();
                String canonicalPath = new File(path).getCanonicalPath();
                int homeDirIndex = canonicalPath.indexOf(homeDir);
        
                if (homeDirIndex != -1)
                {
                    path = canonicalPath.substring(homeDirIndex + homeDir.length() + 1);
                }
        
                return "/download/" + path;
            }
        
      • should be:
            private String prepareDownloadPath(String path) throws IOException
            {
                String homeDir = new File(getBootstrapManager().getConfluenceHome()).getCanonicalPath();
                String canonicalPath = new File(path).getCanonicalPath();
                int homeDirIndex = canonicalPath.indexOf(homeDir);
        
                if (homeDirIndex != -1)
                {
                    path = canonicalPath.substring(homeDirIndex + homeDir.length() + 1);
                }
        
                path = "/download/" + path;
                
                if(ImportExportManager.TYPE_PDF.equals(type)){
                   path += "?contentType=application/pdf";
                }
                //...more types here
        
                return path;
            }
        

              Assignee:
              Ryan
              Reporter:
              Paweł Karpiński
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: