File Upload in Custom Plugin

Bart Gottschalk February 6, 2013

I'm migrating a custom plugin from 4.4.x to 5.2.5 and one of the things we do in this plugin is provide the ability to attach files at the project level. We support this project attachment through ActiveObject and don't rely on any of the built in issue attachment capabilities. Javascript changes between these version include validating that the attachment is less than the JIRA upload size limit and that the uploaded files are associated with an existing issue. The js code also converts the input type="file" element to a checkbox for multiple file uploads.

I'm not providing a different way to create issue attachments. So, the restriction to match an issue id is not applicable. I'm only allowing the user to upload a single file at a time so I don't want to support multiple files. The file upload restriction set in JIRA also doesn't apply and I don't want that validation.

I want to disable all of this new functionality for the custom project attachment form I'm migrating but leave it in place for the standard issue attachment forms. I don't want to modify the out of the box javascript files. Is there a way to do this without editing source js code? If not, why not?

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

3 votes
Answer accepted
Bart Gottschalk February 6, 2013

By reviewing the javascript code I noticed this in initInlineAttach.js:

function createInlineAttach(context) {
        context.find("input[type=file]:not('.ignore-inline-attach')").inlineAttach();
    }

That is what I needed. By simply adding

class="ignore-inline-attach"

to my input type="file" element all of this functionaltiy is turned off.

I hope this helps someone else!

Vikash Kumar
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 23, 2013

Hey @Bart, can you plz help me with the java code for fileupload in JiraWebActionSupport. I am using MultiPartRequestWrapper , but it's null.

Thanks in Adv.

Bart Gottschalk October 23, 2013

Vikash,

If you provide more details about the issue you're having on the server side I or someone else may be able to help you. You may want to start a new question that is about the server side of uploading files in JIRA plugins.

Bart

Vikash Kumar
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 23, 2013

hey @Bart, i have posted a new question at below link. Will you plz provide your valuable input.

why file upload into jira request is text/html instead of multipart/form-data? - Atlassian Answers

Thanks,

Vikash

0 votes
Bruno Conde
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
December 10, 2013

Here is what I find out after a day researching...

http://stackoverflow.com/questions/15761800/single-file-upload-in-jira

0 votes
Timothy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 6, 2013

Just for note if you ever need to support multiple uploads:

  1. Get the "filetoconvert" parameter values. It contains the name of the file
  2. Use the TemporaryAttachmentsMonitor to grab the temporary name/id of the file which is created
  3. Use the TemporaryAttachmentsMonitor to grab the temporary file
  4. Use the TemporaryAttachmentsMonitor to remove the temporary file
Bart Gottschalk February 6, 2013

Thanks for the additional info.

Vikash Kumar
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 27, 2013

Hi Timothy ,

How to get object of TemporaryAttachmentsMonitor in my action class.?

Thanks in adv.

TAGS
AUG Leaders

Atlassian Community Events