Category: Entwicklung
Webentwicklungg, Programmieren, Software, Server… irgendwie alles was in den Bereich Computer und Entwicklung fällt
Anything regarding web-development
Angular multipart/formdata
You would like to upload or post something not as an application/json but as a multipart/formdata. It’s pretty simple, simpler than you would’ve thought 🙂 1. create the FormData instance
|
1 2 3 |
public JSON2FormData() { const fd = new FormData(); } |
then you can use .set or .append methods to add values to the post body of the FormData.
|
1 2 3 4 5 6 7 8 9 10 |
public JSON2FormData() { const fd = new FormData(); fd.set('greeting', 'hello there'); // upload a file, as in `File()` // let's assume our component has a `private file: File = new File()` fd.set('file', this.file, 'filename'); // or file.name instead of 'filename' // or you have an object that you'd like to send as a JSON object // let's assume out component has a `private myobject: object = {}` fd.set('myjson', JSON.stringify(this.myobject)); } |
and finally we upload it…
Read ArticleAngular, EventSource, Go and wasted lifetime
If you have ever used EventSource and Angular and have read all the other blog posts and github issues and Stackoverflow posts and nothing worked, then you’ve probably come here and will happily leave knowing you solved your problem. First of all I use cobra, I know, get to the point. As part of cobra…
Read Articlelibvirt manual migration
Following scenario: You have 2 servers. No shared storage. You would like to move VMs from Server A to Server B. If you want a clean filesystem there will be downtime. Downtime will take as long as it needs to copy the image from one server to the other. Step 1: Shutdown the instance running…
Read ArticleGo database changes notifications over websocket. Generic solution. Reactive apps.
Do you know the problem when you’re writing single page apps and you have to manually update your data from the backend because you know you have just made a change and want the current state to update in “real time”? So you either load the data again by hand/initialite a refresh of the data,…
Read Article