Jira Plugin with File Uploading

I'm trying to create a plugin which needs to read some data from a user-supplied file.

I've tried a normal file-input HTML element in a form in a velocity template and posting to an action Java class (I think that makes sense?) But it seems that no files are passed.

I'm using the Apache ServletFileUpload class along with some others which are supposed to work for exactly what I need. I seem to be doing everything as per the tutorials I've seen around but it's not working. It does however work when I remove the enc-type but just for non-file inputs such as text, passwords etc.

So I've come to the conclusion that Jira is causing these issues.

Anyone done something like this before or know if it's possible?

The "receiving" code:

DiskFileItemFactory fileItemFactory = new DiskFileItemFactory();

ServletFileUpload upload = new ServletFileUpload(fileItemFactory);
FileItemIterator iterator = upload.getItemIterator(request);

List items = upload.parseRequest(request);
Iterator it = items.iterator();

while (it.hasNext()) {
    FileItem item = (FileItem) it.next();
    System.out.println("Got file");
}

Answers


You cannot use both

FileItemIterator iterator = upload.getItemIterator(request);

and

List items = upload.parseRequest(request);

The first is the streaming API and the second is the basic API. Both consume the content. For a given request, you must pick one API and use just that one.


Ended up not using the HTML file upload element. Instead I used a text box where the user will have to enter a public path to the file and then I used the standard Java File class.


Need Your Help

SQL Server 2008 - Shrinking the Transaction Log - Any way to automate?

sql sql-server sql-server-2005 sql-server-2008

I went in and checked my Transaction log the other day and it was something crazy like 15GB. I ran the following code:

How to find checked RadioButton inside Repeater Item?

asp.net javascript repeater radio-button

I have a Repeater control on ASPX-page defined like this: