Here is my problem:
I'm writing an angular app, I use App Engine and Google Cloud Storage as the backend (JAVA 8). Now I have text, and I want to save it to my database. Using cloud storage I need this text to be saved as a file. One manner to do that would be to convert my string into a file Object and send it to server via a multipart request.
How can I do that?
Here is my code so far (the aim of that code is to send a photo plus a text description):
uploadAlbum(index:number){
const formData = new FormData();
//`myPhoto` is a file created with the <input type="file"> tag
formData.append('file', myPhoto, '/gcs/my-bucket/' + index +'/cover/cover.jpg');
//here is my problem here `description` is not a file
formData.append('description', description, '/gcs/my-bucket/' + index +'/cover/cover.txt');
this.http.post('/api/photos',formData).subscribe(
(data: any) => {
response = data;
},
err => {
console.log(err)
}
);
}
As description
variable is a string, I get the following error on my console:
ERROR TypeError: "Argument 2 of FormData.append is not an object."
NOTE: Even if that can seem out of subject I added tags for the backend server on my post as I'm open to solve this issue creating a file on the backend also.