Hi,
Do you guys know how to read the actual data from an attachment file while using Java api?
Prasanna
Community moderators have prevented the ability to post new answers.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you please give more context - is this an issue attachment or some other attachment and what you intend to to with this data ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.