Hi.
I wish to send Jira issue's attachments to another software using json.
The final goal is to produce a json of that kind.
{
"attachments": [{
"b64content": "whatever b64 string ==",
"name": "image.png"
}
]
}I am using scriptrunner do perform this action. It seems like the AttachmentManager.streamAttachmentContent can do the job but I do not know how to use the InputStreamConsumer (Atlassian Jira - Server 9.3.3 API) class.
Here is the code I use so far.
import com.atlassian.jira.component.ComponentAccessor
import groovy.json.*
import org.apache.log4j.Level
import org.apache.commons.codec.binary.Base64;
import com.atlassian.jira.issue.AttachmentManager
import com.atlassian.jira.issue.attachment.Attachment
log.setLevel(Level.INFO);
def issueManager = ComponentAccessor.getIssueManager()
def attachmentManager = ComponentAccessor.getAttachmentManager()
def issue = issueManager.getIssueObject('PTIJ-68')
def attachment_list = issue.getAttachments()
// Once I have the list, I am working on the first attachment right now and try to stream it as a list of bytes but do not know how to open the stream.
log.info(attachmentManager.streamAttachmentContent(attachment_list[0], ??? ))
Can anyone help?