google-cloud-functions

How to trigger firestore cloud functions on update of field value?

扶醉桌前 提交于 2020-01-23 11:42:34
问题 I want to send email to user on update of status field of user to value (true) using firestore and cloud functions. My case : I have a users(collections) which has more documents of userId(documents) and each document contains field and value. One of the field is status: true | false (boolean). I want to send email to that user if status of that user change to true using cloud functions and sendgrid api. users - dOpjjsjssdsk2121j131 - id : dOpjjsjssdsk2121j131 - status : false -

Google pubsub into HTTP triggered cloud function?

为君一笑 提交于 2020-01-23 08:12:13
问题 Is it possible to trigger an HTTP cloud function in response to a pubsub message? When editing a subscription, google makes it possible to push the message to an HTTPS endpoint, but for abuse reasons one has to be able to prove that you own the domain in order to do this, and of course you can't prove that you own google's own *.cloudfunctions.net domain which is where they get deployed. The particular topic I'm trying to subscribe to is a public one, projects/pubsub-public-data/topics

Cloud Functions: how to upload additional file for use in code?

倾然丶 夕夏残阳落幕 提交于 2020-01-23 03:53:07
问题 I need to get access to protoc file in my code. Locally I just put it in the folder but how to get this file from deployed Firebase functions? const grpc = require('grpc'); const PROTO_PATH = __dirname + '\\protos\\prediction_service.proto'; exports.helloWorld = functions.https.onRequest((request, response){ var tensorflow_serving = grpc.load(PROTO_PATH).tensorflow.serving; ... } 回答1: You'd like to upload 3 files to deploy your Cloud Function: index.js package.json prediction_service.proto In

Cloud Functions for Firebase killed due to memory limit exceeded

自闭症网瘾萝莉.ら 提交于 2020-01-22 04:40:07
问题 I keep getting a sporadic error from Cloud Functions for Firebase when converting a relatively small image (2mb). When successful, the function only takes about 2000ms or less to finish, and according to Image Magick documentation should I should not see any problems. I tried increasing the buffer size for the command, which isn't allows from within Firebase, and I tried to find alternatives to .spawn() as that could be overloaded with garbage and slow things down. Nothing works. 回答1: I was

Cloud Functions hidden after uploading to github?

不问归期 提交于 2020-01-22 02:48:07
问题 I have downloaded node.js, and have created the firebase-function files at the website directory (firebase.json, the functions folder and others). If I was to write javascript cloud functions inside the project/functions/index.js file, it won't be private when I upload it to my Github repository for my static website. (something.github.io) So how would I go about calling the firebase cloud functions in my index.js to my static website without uploading the index.js (to keep certain functions

Cloud Function with Schedule

為{幸葍}努か 提交于 2020-01-21 19:20:51
问题 I am trying to do a cloud function by adding a Schedule to change the status of a node inside firebase, which is {active: true} to {active: false} const admin = require('firebase-admin'); admin.initializeApp(); const db = admin.firestore(); exports.createPrd = functions.firestore.document('products/{itemId}').onCreate((ev) => { db.collection('products').doc(ev.id).get().then( doc => { var dia = doc.data().limitDay; var mes = doc.data().limitMonth; var hora = doc.data().limitHour; exports

Cloud Function with Schedule

余生颓废 提交于 2020-01-21 19:20:10
问题 I am trying to do a cloud function by adding a Schedule to change the status of a node inside firebase, which is {active: true} to {active: false} const admin = require('firebase-admin'); admin.initializeApp(); const db = admin.firestore(); exports.createPrd = functions.firestore.document('products/{itemId}').onCreate((ev) => { db.collection('products').doc(ev.id).get().then( doc => { var dia = doc.data().limitDay; var mes = doc.data().limitMonth; var hora = doc.data().limitHour; exports

Sending E-Mail through firebase functions

早过忘川 提交于 2020-01-21 15:13:25
问题 Its there a way to use an API like(sendgrid, mailgun) to send Email through Firebase cloud functions or it is considered as an Outbound connection? 回答1: Assuming you're asking because you're on the free Firebase plan. As explained on the Firebase pricing page: The Spark plan allows outbound network requests only to Google-owned services. Luckily, there is a Google-owned service that allows mail sending; Gmail! There is a quick-start sample available or a related StackOverflow answer, but the

Connect to a database over a unix socket using SQLAlchemy

浪子不回头ぞ 提交于 2020-01-21 12:57:21
问题 I'm trying to connect to my Cloud SQL DB using SQLAlchemy from my cloud function but I can't seem to work out the correct connection string. DATABASE_URL=postgres://$DB_USER:$_DB_PWD@/$DB_NAME?unix_socket=/cloudsql/$DB_INSTANCE Which gives me the error: pyscopg2.ProgrammingError: invalid dns: invalid connection option "unix_socket" What is the correct way to connect to a Postgresql 9.6 DB over a unix socket using pyscopg2 ? 回答1: The special keyword needed here is host : DATABASE_URL=postgres:

Google Cloud Function deployment failure

心已入冬 提交于 2020-01-21 11:45:50
问题 I am new to Google Cloud Platform, and I am trying Google Cloud Functions but it is showing really strange behavior. I'm trying to run the following code: exports.helloPubSub = (event, context) => { const pubsubMessage = event.data; console.log(event.data.attributes); console.log(Buffer.from(pubsubMessage, 'base64').toString()); }; But when I click to create a function, the deployment fails and hardly after trying 8-9 times it gets deployed. The error which it throws is Deployment failure: