I'm experiencing issue with sending multiple files from angular front-end to spring-boot backend. I've tried everything from stack and from net but i couldn't find the answer. Here's my code:
Angular: .ts file:
submit(){
this.uploadedFiles = this.uploadedFiles.map(item => {
let formData = new FormData();
return formData.append('file',item,item.name);
});
this.service.postFile(this.uploadedFiles).subscribe(result => {
console.log(result);
})
}
this.uploadedFiles is somehow undefined of type FormData ?
service file:
postFile(files: any): Observable<string>{
return this.http.post('/id/file', files, {responseType:'text'});
}
spring controller:
@PostMapping(value = "/file")
private String newFile(@RequestBody List<MultipartFile> mf) {
return "error";
}
inside of debugger i've got null for mf list.
The main issue is that for 1 file (when I'm using only MultipartFile) mine code is working.
I'm using PrimeNG's p-fileupload with custom upload event.
