export attachments from JIRA_HOME of the project
Asked by NNJK21:

Hi guys,   

I need help, how to download all attachments form the Issues in the project.  

I can't install Bulk and to do it manual it's gonna take long time, because there is a lot of issues.   
The attachemnts are stored in a folder structure in Jira_home according to ticket keys. I need to keep the structure with the ticket keys.   

Please any suggestion is welcomed.   

Regards


Answers:
author: C?mek_ Dr_ Arif
body: 1. You can use a filter as the following to find all the issues have attachment/s.
   * "**project = PRJ6 AND issuetype = Bug AND attachmentsCount \>=1**"
2. Click on the next/desired issue on the left side (the first one will be selected automatically after the filter is applied)
3. Click on the 3 dots at the right side of the "Attachments"
4. Select "Download all" even there is only 1 attachment
   * So, you have the file/s in a zip file with the name of the issue as in "PRJ6-1366_attachments" and keep the structure with the ticket keys.
5. Repeat the steps 2-4 for all the issues found with the filter.

comments: author: C?mek_ Dr_ Arif
body: Of course always you can try one of the apps in Atlassian Market Place by searching  
[Attachments Manager](https://marketplace.atlassian.com/search?query=Attachments%20Manager%20) .


author: NNJK21
body: ![Screenshot 2024-07-09.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/334365iD416890D91C23B39/image-size/large?v=v2&px=999 "Screenshot 2024-07-09.jpg")Is it okay like this, because am getting error, i can't add the filter.  

![Screenshot 2024-07-09 at 16.40.34.png](https://community.atlassian.com/t5/image/serverpage/image-id/334336i895C99F5703FD96C/image-size/large?v=v2&px=999 "Screenshot 2024-07-09 at 16.40.34.png")


author: C?mek_ Dr_ Arif
body: Please do not attempt to add a filter, just implement it and just use the JQL box to write the query directly, do not copy and past.

If you want to get the info and the fields of the issues, you can use "Export issues" button on the top right always.


author: NNJK21
body: Thanks for the help. Filter created.


author: Dick
body: USE YOURJIRADBNAME  
DECLARE @@MDT nvarchar(255) = 'YOURPROJECTKEY'  
SELECT fa.id, concat(p.pkey,'-',ji.issuenum) as 'Issue', st.pname as 'Status',  
concat('/opt/jira-shareddata', '/data/attachments/', p.originalkey, '/', ceiling((ji.issuenum / 10000))\* 10000, '/', p.originalkey, '-', ji.issuenum, '/', fa.id) as 'path',  
fa.filename, cast(fa.FILESIZE/1024/1024 as decimal(18,2)) as 'Mb'  
FROM fileattachment fa  
join jiraissue ji on ji.id = fa.issueid  
join issuestatus st on st.ID = ji.ISSUESTATUS  
join project p on p.id = ji.project  
WHERE cast(fa.FILESIZE/1024/1024 as decimal(18,2)) \> 0.1 -- Filesize in Mb  
--and ji.UPDATED \< '2022-12-31 23:59:59'  
--and p.pkey in (SELECT p.pkey FROM project p WHERE p.id NOT IN (select entity_id from propertyentry where property_key = 'jira.archiving.projects') ) -- non-archived project  
and p.pkey = @@MDT  
--and st.pname not in ( 'Done', 'Resolved')  
ORDER BY  
p.ID  
--fa.FILESIZE desc  
--fa.filename  
;

-------------------

Above is the MS-SQL script I'm using to get the issues containing attachments.  
You get the IssueID, Issuekey, Status, Path, Filename and the size in Mb. The lines starting with dashes are optional filters and sortings to get on top of the attachments.


author: Dick
body: Hi Nenad,  
For some reason my posted answer is wiped.   
It describes the way how to retrieve filenames and locations on a project basis. I'll post it under this message, in the hope that it won't be deleted as malicious code.

comments: author: C?mek_ Dr_ Arif
body: Hi Dick,

I faced the similar issue and solved it by copying the text from Notepad and then pasting it to this area :)


author: Dick
body: cleaned up double post, apologies.


author: Dick
body: cleaned up double post, apologies.


Tags: data-center

jira-data-center