Query issues with attachment sorted by size is that possible??


Dear Answers community,

We need to archive a whole lot of attachments load. We are hitting storage limit and want to start solving this issue. We will archive some issues and projects but I would also want to have a good criteria to search for issue with a lot of load.

For that I used JQL: "attachments is not empty"

But I can not know what is the size of the attachment. Any suggestion on how to solve this case? I want to have a list of issues with attachments, this list should included attachment size.



7 answers

1 accepted

0 votes
Accepted answer

You will definitely need some code to enable this - something that can go into an issue, check the attachments and display the size. 

Francis is right in that the Script Runner could give you a scripted field that could display the total size of all attachments on an issue, and it's only a few lines of code.

But there's no Script Runner on Cloud, and the restrictions mean that you can't add similar add-ons either.

But, two other options

  1. Write a Connect add-on that can fetch the attachment sizes
  2. Do it externally - run your filter over REST and iterate through the results, pulling the attachment meta-data down over REST.

Both of those would use https://docs.atlassian.com/jira/REST/latest/#api/2/attachment-getAttachment



Hi Nic

Sorry for reviving old threads, but you always seem to be able to help me in here smile

I could really use a script (for ScriptRunner), that can tell me the attachment size per Issue. I managed to find one that gives me number of attachments, but that doesnt really help me unfortunately. 

Hopefully you'll see this,

Best regards Nikolaj 

The following action from JIRA Command Line Interface (CLI) will give you a CSV file of issues and attachments with size:

--action runFromIssueList --jql "project = XXX" --common "--action getAttachmentList --issue @issue@ --file attachmentList.csv --append --outputFormat 2" --clearFileBeforeAppend

Did you consider a scripted field (script runner) which is set with the total size of all attachments related to an issue ?


Hi Francis,


No, did not consider that. I want to know if there is other approaches rather than recurring to scripts. However, thks for your quick reply, I may give it a try if no other option.

Many thks to both. Ill go for that

SQL for JIRA is also an option as the ISSUEATTACHMENTS table supports FILESIZE 

Hi Francis,

I am looking for exactly a script like that, but I can't get it to work. How would you write it? 

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Oct 09, 2018 in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

226 views 6 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you