How to get size of jira issue attachments and add the value in custom field

shankara vijayendran
Contributor
February 10, 2025

 

How to get size of Jira issue attachments and add the attachment size in custom field
If my Jira cloud storage is full I just want to filter using this field and delete attachments of the tickets whose attachments size are high

5 answers

1 vote
Vishal Biyani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 10, 2025

@shankara vijayendran 

This should get you going. 

Create an automation, with a scheduled trigger.

Trigger

In the trigger specify JQL 

project = "TEST" and attachments IS NOT EMPTY

Uncheck below checkbox 

snip.png

 

This will return list of issues that have attachment. Then add Conditions

For demo purpose i just added a log statement to show that this approach works

snip.png

You can add conditions based on file size, and then email list of issues or if you are comfortable, delete attachments from the issue within the automation.

Let me know if this works for you.

1 vote
Mohanraj Thangamuthu
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 10, 2025

Hello, Good day. If you are looking only at specific to attachment size. Then go to Settings >> Products >> Storage management. Thanks

shankara vijayendran
Contributor
February 10, 2025

Hello Mohanraj

Thanks for the input 
But I have automate this since every time I wont be able to go , check and delete
Please let me know if you have any other workaround

0 votes
Hannes Obweger - JXL for Jira
Atlassian Partner
February 11, 2025

Hi @shankara vijayendran

I trust that you'll find an Automation-based solution based on the previous comments!

Just as food for thought: If you're open to solutions from the Atlassian Marketplace, you might want to have a look at the app that my team and I are working on: JXL for Jira.

JXL is a full-fledged spreadsheet/table view for your issues that allows viewing, inline-editing, sorting, and filtering by all your issue fields, much like you’d do in e.g. Excel or Google Sheets.  It also comes with a long list of so-called smart columns that aren’t natively available, including he attachments size, the number of attachments, and several more attachments-related columns.

This is how it looks in action:

attachments-size-v2.gif

As you can see above, you can easily sort and filter by your smart columns. You can also use them across JXL's advanced features, such as support for (configurable) issue hierarchies, issue grouping by any issue field(s), sum-ups, or conditional formatting.

This all just works - so there's no scripting or automation whatsoever required.

Any questions just let me know,

Best,

Hannes

0 votes
Prachi Bolar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 10, 2025

Hi Shankara,

welcome to community :) 

with automation this a bit tricky you can try below 

 

  • Trigger: Issue Updated (or Scheduled Trigger)
  • Condition: Check if the issue has attachments (attachments is not empty)
  • Action: Web Request to get attachment sizes (API call to fetch attachment details)
  • Edit Issue: Store the largest attachment size in the custom field
  • Condition: Check if the attachment size exceeds your threshold (e.g., 10MB){{attachment.size}} > 10485760
  • Action: Web Request to delete large attachments (API call to delete attachment
  • )

You can try something on these lines maybe create two different automation and have the second automation run on the first one

But the best way here is as Mohan suggested to check the file size and delete attachments from there. 

As running this for all projects would also exhaust the automation limit 

Thank You,

Prachi

 

0 votes
Vishal Biyani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 10, 2025

@shankara vijayendran 

 

if you are open to use REST API, then one of the endpoints that can be used is

url = "https://your-domain.atlassian.net/rest/api/3/attachment/{id}"

 

You can read through the documentation at this link

shankara vijayendran
Contributor
February 10, 2025

Hello vishal

Thanks for the input 
I have to fetch details of attachments with high mb size so that I can delete those attachments first

Vishal Biyani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 10, 2025

if you run the below JQL, it will give list of issues that have attachments

attachments IS NOT EMPTY

 Then, you can loop through each issue key, using REST APIs, to find issues that have size > X.

 

Are you looking for other option like automation?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events