0

The issue is that my data structure is not the same in Spring Boot compared to the data in angular. I am probably just missing something silly. Thanks in advance for the help.

Angular Data to Send

My angular service method looks like this

submit(selectedfiles:FileList[]) {
    const formData: FormData=new FormData();
    for(let i=0;i<selectedfiles.length;i++){
      for(let j=0;j<selectedfiles[i].length;j++){
        formData.append('selectedfiles', selectedfiles[i][j]);
      }
    }
    return this.http.post<any>(`${this.baseUrl}/abc/submit123`,formData);
  }

Spring boot controller method looks like this

@PostMapping("/submit123")
public ResponseEntity<ResponseVO> submitApplication(@RequestParam("selectedfiles") List<MultipartFile[]> multifile) throws Exception {
    try {
        Boolean res = blah.submit123(multifile);
        return new ResponseEntity<>(new ResponseVO(res), HttpStatus.OK);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        return new ResponseEntity<>(new ResponseVO(e.getMessage());
    }
}

For the controller I have tried the below but everything returns the same result(a flatted list)

Spring Boot Data Result

@RequestParam("selectedfiles") List<MultipartFile[]> multifile

@RequestParam("selectedfiles") MultipartFile[] multifile

@RequestParam("selectedfiles") MultipartFile[][] multifile

0 Answers0