I have created a custom button on Jira issue screen using script runner and after clicking on the button, a pop-up screen has appeared and on this, added a file attribute.
On form submission, I need to create an issue and attach a file with it.
I am using below code to attach a file-
def bean = new CreateAttachmentParamsBean.Builder()
.file(new File("C:/temp"+filename))
.filename(filename)
.contentType("text/plain")
.author(currentUser)
.issue(issue)
.build()
ComponentAccessor.attachmentManager.createAttachment(bean)
By using this, I am successfully able to attach a file to the issue (after giving absolute file loc like ".file(new File("C:/temp"+filename))").
However, I need to browse the file from <input type="file">. This attribute only returns file name, not the complete location of a file because of security risk and without the full location of the file, code generates an error.