Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-17946

Pdf export - wrong content type.

    XMLWordPrintable

Details

    Description

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

      Attachments

        Activity

          People

            rthomas@atlassian.com RyanA
            b54d95394572 Paweł Karpiński
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: