Working with attachments
The attachments feature is a useful feature in JIRA, and it sometimes helps to manage the attachments on an issue through the JIRA APIs. In this recipe, we will learn how to work with attachments using the JIRA API.
There are three major operations that can be done on attachments, namely Create, Read, and Delete. We will see each of them in this recipe.
Getting ready
Make sure the attachments are enabled in your JIRA instance. You can do this from Administration | System | Advanced | Attachments, as mentioned at http://confluence.atlassian.com/display/JIRA/Configuring+File+Attachments.
How to do it...
All the operations on the attachments can be performed using the AttachmentManager
API. The AttachmentManager
interface can be retrieved either by injecting it in to the constructor or from the ComponentAccessor
class, as shown here:
AttachmentManager attachmentManager = ComponentAccessor.getAttachmentManager();
Creating an attachment
An attachment can be created on an issue...