Working with attachments
In this recipe, we will see how to add attachments to an issue via REST and browse existing attachments.
Getting ready
Create a JIRA REST client as mentioned in the Writing Java client for REST API recipe. Make sure attachments are enabled on the JIRA instance by checking at Administration | System | Advanced | Attachments.
How to do it...
There are three different methods exposed by JRJC to add attachments to an issue. The following are the three options and how they are used.
Using input stream and a new filename
- Create an
InputStream
object from the filepath:InputStream in = new FileInputStream("/Users/jobinkk/Desktop/test.txt");
- Get the issue to attach the file. You can use the
IssueRestClient
object as explained ...
Get JIRA Development Cookbook - Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.