JIRA Unable to Find Attachments

Still need help?

The Atlassian Community is here for you.

Ask the community

For Atlassian eyes only

This article is Not Validated and cannot be shared with customers.

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

Issues1-10,00010,001-20,00020,001-30,000

Workaround

  1. Make a backup of the attachments directory.
    (warning) It is very important to do the above step as the script renames/deletes files.
  2. If you are on a Windows server, ensure that a recent distribution of Perl is installed and is added to the PATH.
  3. Download the Perl script and save it in a directory
  4. Run the below commands:

    perl renameattachments.pl /path/to/attachments_directory

The script performs the following actions:

  1. Replaces spaces in the file names with underscores.
  2. Removes all files that contain the _thumb_ substring.
  3. Renames the files to match JIRA 7+'s new numerical-ID-only format.


Last modified on Mar 21, 2024

Was this helpful?

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