google-cloud-functions

Firebase Cloud Functions get data on real time database onCreate

不打扰是莪最后的温柔 提交于 2021-02-11 14:31:07
问题 const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(); exports.sendNotification = functions.database.ref('/messages/diyetisyen/{uname}/{msgid}/message') .onCreate((snapshot, context) => { let message = snapshot.val(); let uname = context.params.uname; let root = snapshot.ref.root; let token = root.child('/users/' + uname + '/token').ref.token; let payload = { data: { custom_notification: JSON.stringify({ body: message + '', title:

Firebase functions user().onCreate: Pass parameters [duplicate]

≯℡__Kan透↙ 提交于 2021-02-11 14:27:44
问题 This question already has answers here : Should firebase auth onCreate trigger have more data? (1 answer) Firebase Auth+Functions | create user with displayName (1 answer) Closed 8 months ago . I have 2 types of users, admins and normal users. In my firebase database, each admin has a document in a 'texts' collection. So, when a new user is created, I want to check if it is an admin or not. On my Flutter client however, I cant pass any other param than email and password, so how does my

Firestore Cloud Function - Value of external variable not recognized in .then()

心已入冬 提交于 2021-02-11 14:19:30
问题 I am new to Firestore cloud functions, and trying to run a simple function that triggers onWrite() in one collection and based on that, updates value in different one. I am hitting roadblock where value of variable (const array actually), is not recognized inside the ...get().then(snapshot) => {} method. As I understand the outer variable's scope should be inside as well, shouldn't it? What am I doing wrong? Research on this topic led me to concept of Promises, and I tried creating promise

Firebase Cloud Function - Create user with extra information

北城余情 提交于 2021-02-11 13:56:17
问题 I am currently looking for the best way to create a user with additional information in a cloud function. The obvious possibility seems to create a trigger which creates a user document: functions.auth.user().onCreate((user) => { /* Create user document in firestore with base information*/ }); And afterwards add the information to the created document. (Handle the promise) But one way or another I don't feel really satisfied with this solution. I would rather do all this stuff in one go. Does

Firebase emulator cloud function throws cors error when hit from frontend

僤鯓⒐⒋嵵緔 提交于 2021-02-11 13:36:27
问题 I have this function that works perfectly in production however when running locally I get cors errors export const listUsers = functions.https.onRequest(async (req, res) => { res.set("Access-Control-Allow-Origin", "*") const data = await getSomeUsers(10) res.json(data) }) emulators starts fine: cors issue: 回答1: Check this: Deadly CORS when http://localhost is the origin Chrome does not support localhost for CORS requests (a bug opened in 2010, marked WontFix in 2014). To get around this you

Streaming binary data from Google Cloud Storage to Cloud Function

邮差的信 提交于 2021-02-11 13:26:58
问题 I have some large binary files stored in Google Cloud Storage that require byte by byte processing. I would like to do this processing using a Cloud Function, but this would require streaming the binary data through the cloud function. Does anybody have any idea how to do this. I'm using Python 3.7. 来源: https://stackoverflow.com/questions/60273469/streaming-binary-data-from-google-cloud-storage-to-cloud-function

Streaming binary data from Google Cloud Storage to Cloud Function

坚强是说给别人听的谎言 提交于 2021-02-11 13:26:51
问题 I have some large binary files stored in Google Cloud Storage that require byte by byte processing. I would like to do this processing using a Cloud Function, but this would require streaming the binary data through the cloud function. Does anybody have any idea how to do this. I'm using Python 3.7. 来源: https://stackoverflow.com/questions/60273469/streaming-binary-data-from-google-cloud-storage-to-cloud-function

Cloud Function running multiple times instead of once

十年热恋 提交于 2021-02-11 12:49:49
问题 I upload 10 files every day at 11 p.m with a Cron Job to a bucket on GCS. Each file is a .csv with a size from 2 to 30 KB . The file name is always YYYY-MM-DD-ID.csv A Cloud Function is called everytime I am uploading a file into that bucket to send those .csv files to BigQuery. The trigger type is Cloud Storage on finalise/create events. My issue is the following: On BigQuery, each value for each row/columns is multiplied by a multiple. Sometimes it's 1 (so the value is the same), often 2

Choosing between PubSub Backend Function or Http Function

此生再无相见时 提交于 2021-02-11 12:49:02
问题 We are designing out our listening side of Google PubSub and will be using Google Functions for this. There are two choices, push and a backend function. Push using Http and will push messages to the function. backend function uses triggering to invoke the function. Where we are having trouble is deciding which approach may be better for our application. We have not been able to find a list of differences between these two methods within the Google documentation. Some things we have noticed

BigQuery displaying wrong results - Duplicating data from Cloud Function?

对着背影说爱祢 提交于 2021-02-11 12:48:53
问题 I am a junior developer and I was in charge of implementing the Facebook API to an existing project. However, the business team figured out that the Google Analytics results displayed on BigQuery are wrong. They asked me to fix it. This is the architecture: What I have done is: On BigQuery, checking how close/far are the results from Google Analytics. I found there is a pattern, the results I am getting on BigQuery are always either 1, 2 or 3 times the original value of GA. I checked if there