This isn't Struts issue but your underlying servlet message. Anyway, what about trying Struts itself file upload feature. Then ask that another app to http post the file to a file upload action.
Regards. >-----Original Message----- >From: Nikhil P Kookkiri <nikhil.kookk...@sicurosolutions.com> >Sent: Monday, October 8, 2018 12:37 PM >To: user@struts.apache.org >Subject: Struts2 - multipart/related - HttpServletRequest#getParts not working > >I have request coming from another application which is 'multipart/related'. In >the mutlipart request body, I am receiving image/jpeg and application/xml. I >suppose, I should be iterating over the http part obtained from getPaths method >in the HttpServletRequest object and read the stream available on each of the >parts. When I try doing that, I am getting the following error: > >java.lang.IllegalStateException: UT010057: multipart config was not present on >Servlet ERROR [stderr] (default task-2) at >io.undertow.servlet//io.undertow.servlet.spec.HttpServletRequestImpl.verifyMul >tipartServlet(HttpServletRequestImpl.java:523) >ERROR [stderr] (default task-2) at >io.undertow.servlet//io.undertow.servlet.spec.HttpServletRequestImpl.getParts( >HttpServletRequestImpl.java:512) >ERROR [stderr] (default task-2) at >javax.servlet.api//javax.servlet.http.HttpServletRequestWrapper.getParts(HttpSer >vletRequestWrapper.java:375) > >Please let me know the best possible solution for this. > >Here is what I am doing in the code: > > public class TestMultiPart extends ActionSupport implements >ServletRequestAware > { > private InputStream inputStream; > private HttpServletRequest request; > > public String execute() > { > BufferedInputStream bis = null; > BufferedOutputStream bos = null; > try > { > Collection<Part> parts = request.getParts(); > for(Part part : parts) > { > String contentType = part.getContentType(); > System.out.println("Content type is: " + contentType); > File file = getFileToDownload(getContentType(contentType)); > if(file != null) > { > bis = new >BufferedInputStream(request.getInputStream()); > bos = new BufferedOutputStream(new > FileOutputStream(file)); > byte[] bytes = new byte[bis.available()]; > while(bis.read(bytes) > 0) > { > bos.write(bytes); > bos.flush(); > bytes = new byte[bis.available()]; > } > } > } > } catch (IOException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } catch (ServletException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } finally { > if(bis != null) > { > try { > bis.close(); > } catch (IOException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > } > if(bos != null) > { > try { > bos.close(); > } catch (IOException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > } > } > > inputStream = new >ByteArrayInputStream("200".getBytes(StandardCharsets.UTF_8)); > return SUCCESS; > } > > public InputStream getInputStream() { > return inputStream; > } > > public void setInputStream(InputStream inputStream) { > this.inputStream = inputStream; > } > > @Override > public void setServletRequest(HttpServletRequest requestObject) > { > this.request = requestObject; > } > >} > >-- >Best regards, >Nikhil P kookkiri > >Gtalk: nikhil.pk81 >Skype: nikhil.pk81 --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org