We are processing files automatically via Google cloud functions if any file is uploaded to Google cloud storage. We wrote the code using python.
https://cloud.google.com/functions/docs/calling/storage
def hello_gcs_generic(data, context):
"""Background Cloud Function to be triggered by Cloud Storage.
This generic function logs relevant data when a file is changed.
Args:
data (dict): The Cloud Functions event payload.
context (google.cloud.functions.Context): Metadata of triggering event.
Returns:
None; the output is written to Stackdriver Logging
"""
print('Event ID: {}'.format(context.event_id))
print('Event type: {}'.format(context.event_type))
print('Bucket: {}'.format(data['bucket']))
print('File: {}'.format(data['name']))
print('Metageneration: {}'.format(data['metageneration']))
print('Created: {}'.format(data['timeCreated']))
print('Updated: {}'.format(data['updated']))
We want to know who uploaded the file for our logging purpose. I don't see any variable in data and context in the above function which provides user information.
Is there any way to find out who uploaded the file in GCF for GCS triggers?