Last active
July 25, 2018 14:36
-
-
Save wholypantalones/d4e1fa29fbacc4a8d1258f0c92bc84ee to your computer and use it in GitHub Desktop.
Angular 6.x.x multipart form data post
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
// Completey omit the 'ContentType: multipart/form-data' headers | |
// const httpUploadOptions = { | |
// headers: new HttpHeaders({ | |
// 'Content-Type': 'multipart/form-data' | |
// }) | |
// }; | |
const str = JSON.stringify('your Blob or Array'); | |
const fd = new FormData(); | |
const file = new File([str], 'fileName'); | |
fd.append('file', file); | |
this.http.put('path/to/url', fd) | |
.subscribe( | |
data => this.data = data as any, | |
err => 'do something with error' | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment