Spring启动表单数据流上载进度

Spring启动表单数据流上载进度,spring,spring-boot,axios,multipartform-data,form-data,Spring,Spring Boot,Axios,Multipartform Data,Form Data,我使用ReactJS、Bootstrap和Axios将文件上传到spring引导服务器。有一个通过事件回调更新的进度条,如下所示: UploadFilesService.upload(currentFile, (event) => { this.setState({ progress: Math.round((100 * event.loaded) / event.total), }); }) upload(file, onUploadProgres

我使用ReactJS、Bootstrap和Axios将文件上传到spring引导服务器。有一个通过事件回调更新的进度条,如下所示:

 UploadFilesService.upload(currentFile, (event) => {
    this.setState({
      progress: Math.round((100 * event.loaded) / event.total),
    });
  })

  upload(file, onUploadProgress) {
    let formData = new FormData();

    formData.append("file", file);
    return http.post("/upload", formData, {
      headers: {
        "Content-Type": "multipart/form-data",
      },
      onUploadProgress,
    });
  }
Spring启动控制器:

public ResponseEntity<ResponseMessage> uploadFile(HttpServletRequest request) {
...
对于大于1GB的文件,这非常有效,但对于较小的文件,似乎在到达控制器之前上载了几个字节(对于<1MB的文件,进度立即跳到100%,对于50MB的文件,进度跳到13%,对于25MB的文件,进度跳到26%,对于12MB的文件,进度跳到52%)

我现在的问题是:为什么?我怎样才能防止这种情况?调试它的好方法是什么

我的目标是限制上传的带宽,所以我希望从请求到达Web服务器的那一刻起就拥有完全的控制权

multipart.enabled=false
spring.servlet.multipart.enabled=false
spring.http.multipart.enabled=false
spring.servlet.multipart.resolve-lazily=true