Spring boot\'s default MultiPartResolver interface handles the uploading of multipart files by storing them on the local file system. Before the controller method is entered
You could use apache directly, as described here https://commons.apache.org/proper/commons-fileupload/streaming.html.
@Controller
public class UploadController {
@RequestMapping("/upload")
public String upload(HttpServletRequest request) throws IOException, FileUploadException {
ServletFileUpload upload = new ServletFileUpload();
FileItemIterator iterator = upload.getItemIterator(request);
while (iterator.hasNext()) {
FileItemStream item = iterator.next();
if (!item.isFormField()) {
InputStream inputStream = item.openStream();
//...
}
}
}
}
Make sure to disable springs multipart resolving mechanism.
application.yml:
spring:
http:
multipart:
enabled: false