Testing A Cloud Function From Trigerring Event Option
so I have this sort of http cloud function (python 3.7) from google.cloud import storage def upload_blob(bucket_name, blob_text, destination_blob_name): '''Uploads a file to t
Solution 1:
Your upload_blob
function doesn't look like an HTTP Cloud Function. HTTP Cloud Functions take a single parameter, request
. For example:
defhello_http(request):
...
See https://cloud.google.com/functions/docs/writing/http#writing_http_helloworld-python for more details.
Solution 2:
As suggested by Dustin you should add an entry point which parses the json request.
A code snipped for the following request will be as follows:
{"bucket_name":"xyz","blob_text":"abcdfg","destination_blob_name":"sample.txt"}
The entry function will be as follows:
entry_point_function(request):
{
content_type = request.headers['content-type']
if'application/json'in content_type:
request_json = request.get_json(silent=True)
if request_json and'bucket_name'in request_json:
text = request_json['bucket_name']
else:
raise ValueError("JSON is invalid, or missing a 'bucket_name' property")
}
Rename the entry point in the function configuration. For the cloud UI
You need to change
Post a Comment for "Testing A Cloud Function From Trigerring Event Option"