0
votes

I am trying to figure out how to properly connect Google App Engine instances to Firebase Storage Triggers. In my use case, I want each time a video is uploaded to the Firebase Storage, to be transcoded and then readded to that same database.

I can't figure out, however how one goes about properly connecting Firebase Storage to Google App Engine (and succesfully linking).

My plan in Google App Engine, upon a fresh upload to trigger a simple transcoding function, and readd it

def transcode():
    client = storage.Client(PROJECT_ID)
    bucket = client.bucket(PROJECT_ID)
    blob = bucket.blob('sample.mp4')
    with open('/tmp/sample2.mp4', 'w') as f:
        blob.download_to_file(f)
    os.system('rm /tmp/output.webm')
    ret = os.system('/usr/bin/avconv -i /tmp/sample2.mp4 -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis /tmp/output.webm')
    if ret:
        sys.stderr.write("FAILED")
        return "Failed"
    blob = bucket.blob('output.webm')
    blob.upload_from_file(open('/tmp/output.webm'))
    sys.stderr.write("SUCCESS")
    return "SUCCESS"

The last time I need to figure out is how to do this when a new upload is added to a Firebase Storage. Is there a correct way to connect google app engine instances to the Firebase Cloud Store (and only have one instance triggered per upload)

1

1 Answers

2
votes

It's conventional to use Cloud Pub/Sub to communicate items of work between components in Google Cloud Platform.

In the Cloud Function, you would use the Cloud Pub/Sub SDK for node to send a message to your application running in GAE. Then, in GAE, you would listen and respond to messages.

How you actually do this with configuration and code is heavily dependent on the way you need your system to work.