Created
October 9, 2025 17:00
-
-
Save resba/ed12059b7986aa24fde3f352de39bed2 to your computer and use it in GitHub Desktop.
Post with Angular multipart data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| postFile(uri: string, data: any, file: any = null): Observable<any>{ | |
| if(file) { | |
| let t = data; | |
| let formData: FormData = new FormData(); | |
| console.log(file); | |
| formData.append('file', file.originFileObj, file.name); | |
| Object.keys(data).forEach((key)=>{formData.append(key,data[key])}); | |
| data = formData; | |
| } | |
| return this.rest.post(uri, data, {headers: this.headers, withCredentials: true}); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment