File Upload in Jira plugin

I am unable to get a file from a form, still getting a PluginHttpRequestWrapper and not a MultiPartRequestWrapper. I am absolutely sure I have enctype="multipart/form-data" in the form. I will be thankful for any ideas.

atlassian-plugin.xml:

<webwork1 key="test" name="test" i18n-name-key="test.name">
    <description key="test.description">The test Plugin</description>
    <actions>
      <action name="package.action.TestBrowse" alias="TestBrowse">
        <view name="input">/templates/test/browse/input.vm</view>
      </action>
    </actions>
  </webwork1>

input.vm:

<form action="TestBrowse.jspa" id="upload-form" method="post" enctype="multipart/form-data">
            <input type="hidden" name="id" value="10000"/>
            <div id="attach-max-size" class="hidden">10000000000</div>
            <input type="file" name="uploadFile"/>
            <input type="submit"/>
</form>

TestBrowse.java:

@Override
public String doExecute() throws Exception {
  MultiPartRequestWrapper requestWrapper = ServletActionContext.getMultiPartRequest();
  if (requestWrapper == null)
    log.error("Why am I not getting a multipart wrapper?")
  else  {
    ...do something...
  }   
  return returnCompleteWithInlineRedirect("/browse/" + getIssueObject().getKey());
}

5 answers

1 accepted

Hi Bruno,

thank you very much, I will try the first option soon.

Martin

I checked contentType of the request I get in doExecute, and it is application/x-www-form-urlencoded; charset=UTF-8, which is quite strange when I defined multipart/form-data in velocity page...

Hi Martin.

Did you find out why the contentType was not multipart/form-data?

I have exacly the same problem.

Thanks.

Hi, unfortunately not, but I spent a great amount of time a few months ago trying to figure it out. Hope you will have better luck.

Hi, unfortunately not, but I spent a great amount of time a few months ago trying to figure it out. Hope you will have better luck.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

88 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you