Assets attachments corruption - PDF attachment icon shown as word
Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.
Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. 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
Asset attachments saved as PDFs show Word icons on the UI.
Environment
JSM and Assets
Diagnosis
We can investigate this with a HAR file or Database query.
Create a HAR file while loading the page. Please refer to the example given below. Filename has pdf extension but the mimeType is officedocument. For PDF documents we expect this to be application/PDF type.
Har file"filename": "1eff0303-80ac-46b9-89d5-89caac7f878c.pdf", "size": "506.2 kB", "mimeType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "url": "/rest/insight/1.0/attachments/607/1eff0303-80ac-46b9-89d5-89caac7f878c.pdf",
- Validate the same in the database AO_8542F1_IFJ_OBJ_ATTACH table. We expect this to be an application/PDF as given below. If it is a different type like application/vnd.openxmlformats-officedocument.wordprocessingml.document, this will cause the issue.
Cause
It may happen when attachments are created using a third-party plugin or any customized functionality.
Solution
Prior to implementing any changes, it is crucial to conduct thorough testing in a test environment. Additionally, remember to create a backup of the data before proceeding with any modifications.
Update the mimeType field in the AO_8542F1_IFJ_OBJ_ATTACH table. The following query is designed for Postgres, so you may need to adjust the syntax for your specific database.
update "AO_8542F1_IFJ_OBJ_ATTACH" set "MIME_TYPE" = 'application/pdf' where "NAME_IN_FILE_SYSTEM" LIKE '%pdf';