I use Angular 4 and I have this code.
uploadPhoto(file: File):Promise<any> {
var formData = new FormData();
formData.append('req', file);
return this.http.post(`${this.urlApi}/uploadphoto`, formData, {
withCredentials: false,
body: formData,
})
.toPromise()
.catch(this.handleError); }
Then I debug my program on Java Spring. I have in debug panel only parametr "req", but not multipart file. I set headers "multipart/form-data" and "undefined". I set "formData.append('req', file[0]); Also, I used this code:
uploadPhoto2(file:File){
var formData = new FormData();
formData.append('file', file);
var request = new XMLHttpRequest();
request.open('POST', `${this.urlApi}/uploadphoto`);
request.send(formData);
}
I have the same results. In console of chrome I see: Content-Type:multipart/form-data; boundary=----WebKitFormBoundarycE8MNSpWUCwCDLLB
When I send data from Postman (chrome exstension) I have succesfull result. Debug in Java Debug in chrome