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");
}
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.