I am trying to upload a file with Angular and send it to my rest backend Spring. For my angular service, I used the settings here.But I am having 2 issues:
The first one: when I send large zip file: I have this error in my browser: net::ERR_CONNECTION_RESET
; it seems that Angular is not able to send the file to the rest client.
The second one: when my zip file is not too big, the first error is bypassed, but this time, I have this error returned from the rest api: 415 (Type de Support Non Supporté)
.
service Angular
deployement(file: File): void {
console.log("service angular");
let formData:FormData = new FormData();
formData.append('uploadFile', file, file.name);
let headers = new Headers();
headers.append('Content-Type', 'multipart/form-data')
headers.append('Accept', 'application/json');
let options = new RequestOptions({ headers: headers });
this.http.post(URL_API_REST + 'upload', formData, options)
.map(res => res.json())
.catch(error => Observable.throw(error))
.subscribe(
data => console.log('success'),
error => console.log(error)
)
}
my spring rest
@RequestMapping(value = "upload", headers = ("content-type=mulitpart/*"), method = RequestMethod.POST)
@ResponseBody
public HashMap<String, String> uploaderDeploiement(@RequestBody MultipartFile fichierZip){
//java code here
}
Could anyone point out what I am doing wrong?