Querying attachments per file type
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
The content on this page relates to platforms which are not supported. Consequently, Atlassian Support cannot guarantee providing any support for it. Please be aware that this material is provided for your information only and using it is done so at your own risk.
Purpose
To retrieve the list of Jira attachments based on their file type. The results contain the attachment ID, file name, project key, and issue number.
Solution
To retrieve a list where the file type is based on filename extensions run the following query, replacing .png with the file extension you want:
SELECT fa.id, fa.filename, p.pkey, ji.issuenum
FROM fileattachment fa
JOIN jiraissue ji ON ji.id = fa.issueid
JOIN project p ON p.id = ji.project
WHERE LOWER(fa.filename) LIKE '%.png';
To retrieve a list where the file type is based on MIME type run the following query, replacing image/png with the MIME type you want:
SELECT fa.id, fa.filename, p.pkey, ji.issuenum
FROM fileattachment fa
JOIN jiraissue ji ON ji.id = fa.issueid
JOIN project p ON p.id = ji.project
WHERE LOWER(fa.mimetype) = 'image/png';