I know this type of question has asked several times in here and some forums.
What i'm trying to do is upload a file to my server. Down below is my first attempt to set headers to multipart/form-data
. Below is my service for the file upload.
uploadNewFile (formData): Observable<any> {
const headers = new HttpHeaders();
headers.set('Content-Type', undefined);
return this.http.post(environment.baseURL+'api/v1/company/someFileUpload' , formData, {headers: headers})
.pipe(
catchError(this.formatErrors)
);
}
But when i do this, i'm getting this error.
Error: Multipart: Boundary not found
But then after seeing this question(Send multipart/form-data files with angular using $http) i changed my header to this.
const headers = new HttpHeaders();
headers.set('Content-Type', undefined)
But when I changed it like that, I am getting this error.
But when i check an aswer for that error it says that i need to add a handler in here (Uncaught TypeError: Cannot read property 'ngOriginalError' of undefined at getOriginalError - when httpClient returned string)
But i have a handler for my service. Service is pasted in below.
uploadNewFile (formData): Observable<any> {
const headers = new HttpHeaders();
headers.set('Content-Type', undefined);
return this.http.post(environment.baseURL+'someFileUpload' , formData, {headers: headers})
.pipe(
catchError(this.formatErrors)
);
}
How can i solve this?