Google Cloud Function http request
Jul 25, 2021
An HTTP POST request containing a parameter to trigger a cloud function
Use a url to trigger the cf , parameter put on the link after ?
Example: http://asia-esat2-project-id.cloudfunction.net/cfname?date=2020–01–01
Request
def function(request):
args = request.args.to_dict() # request parameter to dict
date = args.date # parameter date
List blobs
gcs = storage.Client() # get Google Clientbucket = gcs.get_bucket('abc') # get bucket blobs = bucket.list_blobs() # list all blobsfor blob in blobs: # each blob if re.match(r'[], blob.name) # condition search blob.namedest_bucket = gcs.get_bucket('xxx') # get a destination bucketdest_name = "{}/{}/{}" % (log_date, log_type, filename) new_blob = bucket.copy_blob(file, dest_bucket, dest_name)
# copy blob to the dest bucket