Writing a Cloud Storage Trigger with Cloud Functions for Firebase, Part 2 - Firecasts

By: Firebase

149   2   7863

Uploaded on 06/06/2017

Cloud Functions for Firebase lets you run managed backend code for your mobile app that extends and connects Firebase features. In this Firecast, Jen will show you how to add to a function to get a download URL from Cloud Storage and write it to the Database.

ImageMagick - https://goo.gl/tp5DrX
Installing Node.js modules with npm - https://goo.gl/SyvyGe
Learn more about regex - https://goo.gl/1KeRD
Install Google Cloud SDK for use on the command line -
Integrate with Google Cloud Platform - https://goo.gl/4v58ad
getSignedUrl documentation - https://goo.gl/h9iuRd

Add the Firecasts playlist! https://goo.gl/n2XqG1
Subscribe to the Firebase Channel: https://goo.gl/9giPHG
Music by http://terramonk.com

Comments (4):

By anonymous    2017-09-20

I agree that you won't want to do all that work client-side! Cloud Functions for Firebase are a good option. You can trigger a function on a write to a path in the database, and then make the change to the other related paths. Check out these resources to find out more:

Getting Started with Cloud Functions for Firebase

GitHub samples

Cloud Functions for Firebase documentation

Writing a Database Trigger

Writing a Cloud Storage Trigger: Part 1

Writing a Cloud Storage Trigger: Part 2

Original Thread

By anonymous    2017-09-20

It looks like you're trying to put a Realtime Database trigger inside your HTTP trigger, which won't have the outcome you're looking for. Instead of using a database trigger, use the Firebase Admin SDK to access the database from within the HTTP trigger.

In your code, add

const admin = require('firebase-admin');
const ref = admin.database().ref();

And use ref to access the database.

Check out the Admin SDK documentation here.

Here are some samples of Cloud Functions, some of which show the Admin SDK.

Here's a video showing how to use the Admin SDK

Here's a video on timing Cloud Functions

Original Thread

Popular Videos 27

Submit Your Video

If you have some great dev videos to share, please fill out this form.