JIRA Unable to Find Attachments
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
Symptoms
Users receive an "Unable to retrieve attachments" message when trying to download attachments even though all the files exist on the filesystem.
Diagnosis
Attachments can go missing either from encoding issues prior to the upgrade or from the migration process after the upgrade.
Cause
JIRA versions 4.2 and earlier were used to store the file attachments with the name format "Internal ID + name of the file
" as shown below:
<JIRA_HOME>/attachments/<PROJECT>/<ISSUE_ID>/<ID>_name_of_the_file
This change was done as storing attachments with "name" causes text encoding issues that can result in JIRA being unable to find the attachments. As a result in the later versions of JIRA the attachment structure was changed to use the purely numerical ID in the file name as shown below:
<JIRA_HOME>/attachments/<PROJECT>/<ISSUE_ID>/<ID>
From version 7 to the latest version (9.1) the file path for storing attachments received an update:
Attachments are stored in the following directory: $JIRA_Home/data/jira/data/attachments/PROJECT_KEY/x0000/ISSUE_KEY/ID
where the subdirectory x0000 is created and numbered according to the number of issues on the JIRA instance. It uses the following pattern:
Directory name | 10000 | 20000 | 30000 |
---|---|---|---|
Issues | 1-10,000 | 10,001-20,000 | 20,001-30,000 |
Workaround
- Make a backup of the attachments directory.
It is very important to do the above step as the script renames/deletes files.
- If you are on a Windows server, ensure that a recent distribution of Perl is installed and is added to the PATH.
- Download the Perl script and save it in a directory
Run the below commands:
perl renameattachments.pl /path/to/attachments_directory
The script performs the following actions:
- Replaces spaces in the file names with underscores.
- Removes all files that contain the _thumb_ substring.
- Renames the files to match JIRA 7+'s new numerical-ID-only format.