Unable to preview attachments using the new file preview in a page after upgrade to 5.7 and later versions

Still need help?

The Atlassian Community is here for you.

Ask the community

This Knowledge Base article was written specifically for the Atlassian Server platform. Due to the Functional differences in Atlassian Cloud, the contents of this article cannot be applied to Atlassian Cloud applications.

Problem

After upgrading to Confluence 5.7 and above, attachment link in a page does not open a preview of the file. 

The following message is displayed:

We can't preview this file
You'll have to download the file to view it


Observed issues are with PDF type attachments, JPEG and PNG images

The following appears in the atlassian-confluence.log

2015-02-17 07:48:56,813 ERROR [conversion-thread-3-internal] [conversion.impl.runnable.ConversionRunnable] doWork Format cannot be converted
 -- referer: http://testserver:8090/display/TS/Incident+and+Problemmanagement?preview=/17663912/17795772/How%20To%20Code%20In%20Java.pdf | url: /rest/documentConversion/0.1/conversion/convert/17795772/1 | userName: tester

Diagnosis

  1. A newly inserted attachments can be previewed by clicking on its link.
  2. The file itself is downloadable

Diagnostic Steps

  • Try to replicate this in all browsers
    1. Navigate to an existing page that has PDF Attachment link embedded
    2. Click on the PDF link
  • Generate a HAR file and check when clicking on the old attachment link. Instead of getting the 'Resource', a 'HEAD' is returned when the command "byAttachmentIds" and "minusAttachmentIds" are sent
  • Run the following SQL query:
    • If there are rows returned, please continue to the Resolution section. If it returns empty result, you are not being affected by the issue in this article. Please contact Atlassian Support to assist you.
 SELECT * FROM CONTENTPROPERTIES WHERE PROPERTYNAME = 'MEDIA_TYPE' AND STRINGVAL LIKE '%pdf%';
 SELECT * FROM CONTENTPROPERTIES WHERE PROPERTYNAME = 'MEDIA_TYPE' AND STRINGVAL LIKE '%pjpeg%';
 SELECT * FROM CONTENTPROPERTIES WHERE PROPERTYNAME = 'MEDIA_TYPE' AND STRINGVAL LIKE '%x-png%';

Cause

The Content Type of the attachments are wrong

  • PDF Attachment isnot 'application/pdf' as how it should be, instead the Content Type is either in one of this format; 'pdf', 'image/pdf' or 'application/x-pdf'. 
  • JPEG images isnot 'image/jpeg' as how it should be, instead the Content Type is either in one of this format; 'image/pjpeg'. 
  • PNG images isnot 'image/png' as how it should be, instead the Content Type is either in one of this format; 'image/x-png'. 

These values are already invalid before performing the upgrade.

For more information please refer to  CONF-36666 - Getting issue details... STATUS .

Resolution

Run the following SQL query:

  • For issues with PDF:

    UPDATE contentproperties SET STRINGVAL = 'application/pdf' WHERE PROPERTYNAME = 'MEDIA_TYPE' AND STRINGVAL LIKE '%pdf%';
  • For issues with JPEG images:

    UPDATE
        contentproperties
    SET
        stringval = replace(stringval, 'image/pjpeg', 'image/jpeg')
    WHERE
         PROPERTYNAME = 'MEDIA_TYPE';
  • For issues with PNG images:

    UPDATE
        contentproperties
    SET
        stringval = replace(stringval, 'image/x-png', 'image/png')
    WHERE
         PROPERTYNAME = 'MEDIA_TYPE';
  • Flush your Confluence caches by navigating through Confluence Administration Panel >> Cache Management >> Flush All.

Always backup your data before performing any modifications to the database.

Description

After upgrading to Confluence 5.7 and above, attachment link in a page does not open a preview of the file. This page outlines how to resolve this issue.

Product Confluence
Last modified on Oct 15, 2018

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.