I've faced a problem uploading big files through zuul. I'm using apache-commons file upload(https://commons.apache.org/proper/commons-fileupload/) to stream large files as well as I use zuul on the front. In my Spring Boot application I have disabled upload provided by Spring to use the one from apache commons:
spring:
http:
multipart:
enabled: false
Controller looks like that:
public ResponseEntity insertFile(@PathVariable Long profileId,
HttpServletRequest request) throws Exception {
ServletFileUpload upload = new ServletFileUpload();
FileItemIterator uploadItemIterator = upload.getItemIterator(request);
if (!uploadItemIterator.hasNext()) {
throw new FileUploadException("FileItemIterator was empty");
}
while (uploadItemIterator.hasNext()) {
FileItemStream fileItemStream = uploadItemIterator.next();
if (fileItemStream.isFormField()) {
continue;
}
//do stuff
}
return new ResponseEntity(HttpStatus.OK);
}
If I access my application directly(without zuul), file upload works as intended. However, if it's accessed through zuul, FileItemIterator doesn't have items to traverse and request finishes with error immediately(ERR_CONNECTION_RESET). For zuul I have also disabled multipart given by Spring. Otherwise, it works. However, the files are not streamed. They are loaded completely and only after I get inside the controller(regular Spring behavior). Is there a way to use apache-commons streaming options with zuul?