A file is available at my server's endpoint http://xyz/file
.
I want to send this file in Angular 6 via HTTP POST using multipart/form-data. Thanks to this related question, this is my approach:
const filePath = 'http://xyz/file'
const formData = new FormData();
formData.append('file', filePath);
this.http.post(endpoint, formData).subscribe(response => {
console.log(response);
});
The problem is, this doesn't seem to work if I specify a file path to the file's endpoint rather than the file itself. When trying this, I get an error in the console ERROR TypeError: "Argument 2 of FormData.append is not an object."
.
How can I solve this? Can I somehow use the remote file for the POST? Or do I need to download the file first and then send it? How would I do that?