Took me a few days to find out, but here it is, and it works, you can read multi-part data, files and parameters, here is the code:
try { ServletFileUpload upload = new ServletFileUpload(); FileItemIterator iterator = upload.getItemIterator(req); while(iterator.hasNext()){ FileItemStream item = iterator.next(); InputStream stream = item.openStream(); if(item.isFormField()){ if(item.getFieldName().equals("vFormName")){ byte[] str = new byte[stream.available()]; stream.read(str); full = new String(str,"UTF8"); } }else{ byte[] data = new byte[stream.available()]; stream.read(data); base64 = Base64Utils.toBase64(data); } } } catch (FileUploadException e) { e.printStackTrace(); }
source share