Testing a Cloud Function from Trigerring Event option

你离开我真会死。 提交于 2020-12-15 06:42:14

问题


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 the bucket."""
    storage_client = storage.Client()
    bucket = storage_client.get_bucket(bucket_name)
    blob = bucket.blob(destination_blob_name)

    blob.upload_from_string(blob_text)

    print('File {} uploaded to {}.'.format(
        source_file_name,
        destination_blob_name))

Now I want to test this function from Testing tab of the Functions details page where it asks for triggering event in JSON format.

i tried with various formats like

{
    "name":[param1,param2,param3]
}

but always ended up getting error

upload_blob() missing 2 required positional arguments: 'blob_text' and 'destination_blob_name'

Also tried to find out any documentation but was unable to do so, can you help in pointing to the right direction


回答1:


Your upload_blob function doesn't look like an HTTP Cloud Function. HTTP Cloud Functions take a single parameter, request. For example:

def hello_http(request):
    ...

See https://cloud.google.com/functions/docs/writing/http#writing_http_helloworld-python for more details.



来源:https://stackoverflow.com/questions/65148708/testing-a-cloud-function-from-trigerring-event-option

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!