I have a problem with getting file object by attachment of an issue.
I am using Jira 8.6.1.
I have looked similar question and tried all that was written there, but these approaches don't work.
Else I have found AttachmentUtils.class. It is deprecated, but it has getAttachmentFile() method that directly returns File object by attachment. It also hasn't worked. All of my test breaks by exists() method of the File.class (returns 'false' all the time).
Could you help me with resolve this problem?
What exactly are you trying to do with the file? You can try this to get the attachments.
def attachments = ComponentAccessor.attachmentManager.getAttachments(issue)
Let me know if this helps.
String filePath = PathUtils.joinPaths(ComponentAccessor.getAttachmentPathManager().getDefaultAttachmentPath(), issue.getProjectObject().getKey(), issue.getKey(), attachment.getId().toString());
File file = new File(filePath);
File file = AttachmentUtils.getAttachmentFile(attachment)
All of these approaches return that the file doesn't exist
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events