It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to get complete location of file to upload in Jira using scriptrunner Edited

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.

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

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

Events near you