I am sending FormData()
to a cloud function with something like this in the JavaScript frontend.
//Frontend Angular
const formData = mew FormData();
formData.append('file1', zipFile1);
formData.append('file2', zipFile2);
formData.append('name', 'MyFiles');
this.http.post(urlAPI, formData) //angularJS
//Cloud Function
function main(param) {
console.log(param);
}
The console log on the param
shows the content-type
is multipart/form-data
is in the header.
There is also a property labeled as __ow_body
. This value is a very long string of characters and digits. I am unsure what this is but I am assuming it is the files I am sending in stream/serialized format.
{
__ow_body: 'hf381fh891hv831h93n19384v938v892vn98vn2890vn29n9vn9892vn948vn2893vn2985hv98...'
}
I wanted to confirm if this is the stream data, and if so, how can I parse this?
I need to send this file, which is a zip file containing images, to a API I am using. In this documents API, the examples show sending a file in the local file system such as
someApiFunction('./myImgs.zip').then(...);
The problem lies in me sending my zip file over http network protocol and the format is very different I think from the example of reading a file in the local file system/machine. How can I deserialize/ or parse my file so that it can be recognized as a zip file containing images inside?
I tried using fs.createReadStream
but it doesn't seem to be parsing it. It will just make a more structured object, but within that object, I don't see my formData
and its keys such as file1
file2
and name
.
Do I need to write this file some where first?