I want to implement post file and Json data in the same request .
below is the upload file code :
upload(url:string,file:File):Observable<{compl
The way my manager @Jesse come up with is like:
public uploadFiles(id: ServerID, brd: File, sch: File, args: any[]): Observable {
const data = new FormData();
data.append('brd', brd);
data.append('sch', sch);
data.append('data', JSON.stringify(args));
return this.httpClient.post(URL, data, {
responseType: 'blob',
});
}
The definition of the FormData append() is append(name: string, value: string | Blob, fileName?: string): void; which allows you to append JSON parameters to it or upload a file.