Problems to preview attachments in Confluence, Error rendering macro 'view-file'
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
Attachments aren't displayed on the page and preview isn't working. Using the View File macro may error out with Error rendering macro 'view-file':
Environment
This problem was identified in Confluence server and datacenter version 7.11.0 but, due to the nature of the problem, it can affect most versions of Confluence.
Diagnosis
Attachments can't be previewed and aren't displayed on pages. It's possible to find more about the problem by analyzing the file atlassian-confluence.log
and looking for the following errors:
com.atlassian.confluence.pages.AttachmentDataNotFoundException: Problem while getting attachment stream
ERROR [http-nio-8090-exec-16] [[Standalone].[localhost].[/].[noop]] log Servlet.service() for servlet [noop] in context with path [] threw exception
java.io.FileNotFoundException: /data/confluence/sharedhome/dcl-thumbnail/11/11/44536111/118956102_8 (Permission denied)
WARN [http-nio-8090-exec-4] [atlassian.confluence.pages.DefaultAttachmentManager] getAttachmentData Could not find data for attachment: Attachment: filename test - java.io.FileNotFoundException: /data/confluence/sharedhome/attachments/ver003/111/111/45383611/11/11/44536111/118956111/1 (Permission denied)
Cause
The root cause reported in this KB is related to Permission denied to the folder where the attachments reside as seen in the aforementioned errors. By not having the correct permissions, Confluence won't be able to retrieve the attachment from the file system to be displayed in its UI.
It's also possible that the attachments are actually missing from the file system. In this case, refer to How to resolve missing attachments in Confluence.
Solution
File system permissions depend on the operational system, we recommend following How to set file system permissions for Confluence Data Center to resolve this problem.