Search code examples
androidfirebasegoogle-cloud-platformgoogle-cloud-storagefirebase-storage

Google's Firebase. Is it possible to send email notification if something was uploaded to storage?


I have created an application that uploads pictures to google's Firebase and was wondering is it possible to create something that will send email notification with that file view link? Or should I create something in app that send email when picture has been uploaded.


Solution

  • Yes, you can write a Cloud Function that will be triggered (in the back-end, in a "trusted environment") when a file is uploaded to Cloud Storage and sends a mail via Sendgrid (solution recommended by Firebase).

    Have a look at:

    https://firebase.google.com/docs/functions/gcp-storage-events for Cloud Storage triggering

    and at

    https://cloud.google.com/functions/docs/tutorials/sendgrid for sending an email via Sendgrid.

    Also, have a look at these official samples: mail and storage trigger

    As a Google cloud platform user you get a free quota of 12000 mails a month with Sendgrid. See https://console.cloud.google.com/launcher/details/sendgrid-app/sendgrid-email

    Do not hesitate to ask for more help if you encounter difficulties in implementing/adapting the code of these examples to your case.