Hi All,
I have added the field "Attachment" to the transition screen and i am attaching file. I wanted to get the value from this field.
Please provide a code snippet to get the information.
Thanks
The field does not have a value.
You need to work with a file that Jira needs to retrieve for you which is very different from a field value. Could you explain exactly what you want to do with the attachments here?
For eample, do you need the information about where the user is uploading from? The content of the file? The file name the user gives? The file name Jira will use on disk? Something else?
Hi Nic,
Thanks for the response. I need to get the file name of the attached file and then get its information like md5checksum etc.
Regards
Binisha
Ok,
You need to create or obtain an attachmentManager object in your code, then you can use the function getAttachments(Issue) to get the list of attachments. You can then get some more information from the attachment objects - getAuthor, getFilename and so-on. There's no md5 function built-in, you'll need to code that for yourself
List<Attachment> attachments = this.attachmentManager. getAttachments(issue); for (Attachment attachment : attachments) { System.out.println(attachements.getFilename()); // Apply the logic to retrieve the content of the file }
The main goal is to get the name of the file that we are attaching and add the filename to a field using postfunction.
And also before attaching we need to compare whether this file is existing, by generating the checksum of the file we are attaching and comparing with the files, which are already attached. If the file exists then we need to throw an error to the user. - Validator
Is this feasible?
It looks like you're new here. Sign in or register to get started.