google-cloud-functions

How to scope Firebase in nested promise Cloud Functions

若如初见. 提交于 2020-01-25 21:42:06
问题 I am trying to set a few variables from Firebase and then pass those into a anotherfunction. Currently, the Promise.all is properly setting foo and bar, but an error is being thrown during the .then , so the response isn't getting set in Firebase. const functions = require('firebase-functions'), admin = require('firebase-admin'); admin.initializeApp(functions.config().firebase); exports.someFunc = functions.database.ref(`/data`).onWrite(event => { const condition = event.data.val() if

How to use curl to send file to Google Cloud Function?

╄→гoц情女王★ 提交于 2020-01-25 09:34:11
问题 I have the following Cloud function which is mainly based from the documentation: def hello_world(request): if request.method == 'GET': print('GET') elif request.method == 'PUT': print("PUT") # This code will process each file uploaded files = request.files.to_dict() print("files: ",files) for file_name, file in files.items(): file.save(get_file_path(file_name)) print('Processed file: %s' % file_name) # Clear temporary directory for file_name in files: file_path = get_file_path(file_name) os

How to fix “Missing or insufficient permissions at Http2CallStream”

冷暖自知 提交于 2020-01-25 09:13:08
问题 I'm trying to update firestore document from cloud function using nodejs, but getting error error Logs : Error: Missing or insufficient permissions. at Http2CallStream.call.on (/srv/node_modules/@grpc/grpc- js/build/src/client.js:101:45) at emitOne (events.js:121:20) at Http2CallStream.emit (events.js:211:7) at process.nextTick (/srv/node_modules/@grpc/grpc-js/build/src/call- stream.js:71:22) at _combinedTickCallback (internal/process/next_tick.js:132:7) at process._tickDomainCallback

How do I write/update data to multiple child nodes via Firebase Cloud functions?

蹲街弑〆低调 提交于 2020-01-25 08:17:30
问题 I've got a database that looks like this: I want to reset the Patient_List and Current_Token children to 0 at a particular time (say 12 AM) automatically for all the users in the database. I went through the Firebase cloud function docs and these projects on gitHub: Deleting nodes and Delete unused user accounts using Cron. Both of the above examples update and change data based on a particular UID i.e update only particular nodes based on the UID passed. I would like to know if it is

How do I write/update data to multiple child nodes via Firebase Cloud functions?

ε祈祈猫儿з 提交于 2020-01-25 08:17:26
问题 I've got a database that looks like this: I want to reset the Patient_List and Current_Token children to 0 at a particular time (say 12 AM) automatically for all the users in the database. I went through the Firebase cloud function docs and these projects on gitHub: Deleting nodes and Delete unused user accounts using Cron. Both of the above examples update and change data based on a particular UID i.e update only particular nodes based on the UID passed. I would like to know if it is

Only Receiving Part of Apple Subscription Notification in Google Cloud Function

依然范特西╮ 提交于 2020-01-25 08:07:33
问题 I am trying to set up a Google Cloud Function (GCF) to handle Subscription Notifications from Apple. I am familiar with GCF, but not very familiar with writing my own REST API and the Nodejs methods of handling the data Apple sends with the notification. I am receiving the Apple notification, but only a "chunk" of it. Here's my code (using express and body-parser frameworks). I put my whole function here to help people since there is absolutely nothing about how to use GCF for Subscription

Stripe function cannot be found

佐手、 提交于 2020-01-25 07:24:48
问题 I am using Stripe in my angular7 application to handle payments via firebase cloud functions. I am currently trying to create a subscription payment. However, when I try and call the following function (as a sort of pre-req to the whole subscription setup); import * as Stripe from 'stripe'; const stripe = new Stripe('pk_test_....'); //Create payment method for customer const {paymentMethod, createPaymentMethodError} = await stripe.createPaymentMethod({ type: 'card', card: cardElementObj.card,

How to access endpoint from express router in Cloud Functions Shell

半城伤御伤魂 提交于 2020-01-25 06:57:27
问题 (Note: I'm using javascript, not typescript in my Functions) My Firebase Project has a single 'oauth' function, which has a series of endpoints created through express app/routers. I don't understand how to run the functions at these endpoints from the Cloud Functions Shell to debug them locally. Here is my index.js const twitter = require("./oauth/twitter"); const app = express(); app.use("/signin/twitter", twitter.router); exports.oauth = functions.https.onRequest(app); My actual endpoints

How to trigger a dataflow with a cloud function? (Python SDK)

北城余情 提交于 2020-01-25 06:49:27
问题 I have a cloud function that is triggered by cloud Pub/Sub. I want the same function trigger dataflow using Python SDK. Here is my code: import base64 def hello_pubsub(event, context): if 'data' in event: message = base64.b64decode(event['data']).decode('utf-8') else: message = 'hello world!' print('Message of pubsub : {}'.format(message)) I deploy the function this way: gcloud beta functions deploy hello_pubsub --runtime python37 --trigger-topic topic1 回答1: You have to embed your pipeline

Failed to configure trigger providers/cloud.firestore/eventTypes/document.update

Deadly 提交于 2020-01-25 06:05:42
问题 I plan on updating the news_author_user_type every time an update happens on user_type in users node Here's my code exports.onUpdateUserType = functions.firestore .document('users/{user_id') .onUpdate((change, context) => { const newUserDoc = change.after.data(); const user_type = newUserDoc.user_type; const user_id = context.auth.uid; const db = admin.firestore(); const newsRef = db.collection('news').where('news_author_id', '==', user_id); const news = newsRef.get().then(onSnapshot => {