Hi Roman,
Thank you very much for kindly help.
We will try as suggestion.
By other way, we have used HttpServletRequest interceptor solution is working too.
For some one who have the same issue, here is working code:
public class MyVaadinServlet extends JmixVaadinServlet {
@Autowired
protected FileScanService fileScanService;
public MyVaadinServlet(ApplicationContext applicationContext) {
super(applicationContext);
}
@Override
protected void service(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
// Check file upload request
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
if(isMultipart){
CachedBodyHttpServletRequest reqNew =
new CachedBodyHttpServletRequest(request);
InputStream reqIs = reqNew.getInputStream();
FileScanResponse scanResponse = fileScanService.scanFiles(reqIs);
if(scanResponse !=null && Boolean.TRUE.equals(scanResponse.getDetected()) ){
throw new IOException("File upload maybe content the virus. Please upload again");
}else {
super.service(reqNew, response);
}
}else {
super.service(request, response);
}
}
}
The class "CachedBodyHttpServletRequest " you can refer in https://www.baeldung.com/spring-reading-httpservletrequest-multiple-times