Rank 3: Container
def main(req, res):
"""This function transcribes any audio file that is put into the bucket audio-files"""
# Setup of various services
client = Client()
(
client.set_endpoint(req.variables.get("APPWRITE_FUNCTION_ENDPOINT", None))
.set_project(req.variables.get("APPWRITE_FUNCTION_PROJECT_ID", None))
.set_key(req.variables.get("APPWRITE_FUNCTION_API_KEY", None))
)
storage = Storage(client)
# Get the event data
event_data = json.loads(req.variables.get("APPWRITE_FUNCTION_EVENT_DATA", None))
event_name = req.variables.get("APPWRITE_FUNCTION_EVENT", None)
return res.json(
{
"event_name": event_name
}
)
I have the following functin it runs twice each time I run it on trigger of an event when a file is created in the bucket. I am uploading via the appwrite cloud console.
Get following as event
in respnse of both {"event_name":"buckets.647b122c985261158060.files.647f2a9b73d3aca5f718.create"}
{"event_name":"buckets.647b122c985261158060.files.647f2a9b73d3aca5f718.create"}
This happens when the file is more that 5mb