I would like to pass data to my cloud function from a local JSON file by using the command gcloud functions call <MY-FUNCTION>
.
I can successfully pass data following the official docs but I would like to know if there's a way to do such a thing:
gcloud functions call <MY-FUNCTION> --data './path/to/my/file.json'
Copy pasting the data works, but it gets inconvenient as it might contain hundreds of lines worth of information.
Is there a way to do such a thing? Perharps a workaround by using something different from the gcloud CLI?
Thanks!
You can do this:
gcloud beta functions call [[YOUR-FUNCTION]] \
--data="$(cat ./path/to/your/file.json)" \
--region=[[YOUR-REGION]] \
--project=[[YOUR-PROJECT]]
Alternatively, you can do this with curl:
curl \
--data @./path/to/your/file.json \
https://[YOUR-REGION]]-[[YOUR-PROJECT]].cloudfunctions.net/[[YOUR-FUNCTION]]