I have Controller Method as below :
@RequestMapping(method = RequestMethod.POST, consumes = "multipart/form-data", produces = "application/json")
public void saveUpdate(@RequestPart("org") Organization org, @RequestPart("logo") MultipartFile file){
LOG.info("ORG :"+org != null ? org.getName()+" : " + file : null);
}
In Angular I am sending Form Like below :
public saveUpdateOrganization(organization: Organization, file: File): Observable<void> {
let headers = new Headers({ 'Content-Type': 'multipart/form-data', 'Access-Control-Allow-Origin': '*' });
let options = new RequestOptions({headers: headers});
let formData = new FormData();
formData.append("logo",file);
formData.append("org", new Blob([JSON.stringify(organization)],
{
type: "application/json"
}));
return this.http.post(AppSettings.API_ENDPOINT + "org", organization, options).map((response) => {
return;
})
}
Where is the issue here? and Where it is needed the correction.
Please Suggest.