Attachments and SOAP
In this recipe, we will see how to add attachments on an issue via SOAP and browse existing attachments.
Getting ready
As in the previous recipes, create a JIRA SOAP client. Also, make sure attachments are enabled on the JIRA instance.
How to do it...
Since JIRA4, attachments are added into an issue using addBase64EncodedAttachmentsToIssue
method where as pre JIRA4 addAttachmentsToIssue
method was used. The latter is still available though it is deprecated. There is also a known issue with the latter where it fails on large attachments.
Following are the steps to add attachments on an issue using addBase64EncodedAttachmentsToIssue
method:
Create a File object using the path of the file to be uploaded. The file should be accessible via a valid URL.
File file = new File("var/tmp/file.txt");
The path should be valid in the context.
Read the contents of file into a Byte array:
// create FileInputStream object FileInputStream fin = new FileInputStream(file); /* * Create byte array...