Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,327,567
Community Members
 
Community Events
168
Community Groups

Getting binary data from attachment files in Jira using Java.

Hi,

Do you guys know how to read the actual data from an attachment file while using Java api?

Prasanna

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

And, for Jira 6.2

String filePath = PathUtils.joinPaths(ComponentAccessor.getAttachmentPathManager().getDefaultAttachmentPath(), issue.getProjectObject().getKey(), issue.getKey(), attachment.getId().toString());
					File file = new File(filePath);
					if (file.exists()) {
						// attachments file exists...
					}

Sometimes this can not work due project renaming issues;

I've been using this way to retrieve the attatchment File object when needed. Maybe this method can help you too;

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.attachment.FileSystemAttachmentDirectoryAccessor
import com.atlassian.jira.issue.Issue

File getAttatchmentFile(Issue issue,String attatchmentId){
    return ComponentAccessor.getComponent(FileSystemAttachmentDirectoryAccessor.class).getAttachmentDirectory(issue).listFiles().find({
        File it->
         it.getName().equals(attatchmentId)
    });
}

Regards, Italo Qualisoni

Like Neta Elyakim likes this

Can you please give more context - is this an issue attachment or some other attachment and what you intend to to with this data ?

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS

Atlassian Community Events