google-cloud-functions

How to pass parameters to the cloud function of firebase

▼魔方 西西 提交于 2021-01-28 02:52:58
问题 I am using Android. After the user logs in to firebase, how can I retrieve the user information in the firestore according to the account? My function is in the cloud function of firebase. My code as follows: mFunctions.getHttpsCallable("getInfo").call() .continueWith(new Continuation<HttpsCallableResult, Object>() { @Override public String then(@NonNull Task<HttpsCallableResult> task) throws Exception { Log.d("-----TEST-----", "BEGIN000"); Object result = task.getResult().getData(); Log.d("-

Pass user auth to Firestore from Cloud functions

ぃ、小莉子 提交于 2021-01-28 00:23:01
问题 So I'm trying to build an http endpoint using a Cloud function. This cloud function is only invoked after the user signs in. So I can pass the user token and verify it on the server side. I understand how to do this. I also have security rules on my Firestore collections with authorization rules set up using request.auth.uid. This also just works if I use the firebase web sdk. But my question is - how do I use the same authorization rules via cloud functions? I don't want to rewrite my auth

Firebase cloud function typescript error “Not all code paths return a value”

前提是你 提交于 2021-01-27 23:48:39
问题 I am using firebase cloud function and firestore transaction to decrease the available quantity of product based on purchases. At the time of deploy it returns the error "error TS7030: Not all code paths return a value" Here is the code import * as functions from 'firebase-functions'; import * as admin from 'firebase-admin'; admin.initializeApp(); const db = admin.firestore() exports.newOrder = functions.firestore .document('orders/{orderId}') .onCreate(async (snap, context) => { try { const

javascript - how to use promises in firebase?

好久不见. 提交于 2021-01-27 23:19:59
问题 Lately I've been stuck with a problem that I don't know how to solve. I asked this question and after some efforts we've found that Firebase works differently with promises than normal requests, and I couldn't use them properly. As explained in the question, I'm filling an array with some informations from Firebase, and I need to call another method when I'm sure the array is filled, in other words when I'm sure the call to Firebase has finished. This is my code as I'm using it now: var user

Memory profiler for Google cloud function?

匆匆过客 提交于 2021-01-27 20:49:41
问题 I'm running a Google cloud function and getting out-of-memory error: Error: memory limit exceeded. Function invocation was interrupted. However, when I profile it locally, it doesn't use more than 500-600Mb (My gcf memory allocation is 2Gb) Is there a way to have a line-by-line profiler to a) to see which steps result in highest memory increases, and b) view current memory usage of the cloud function? 回答1: This is precisely what Stackdriver Profiler is for, however Python support is currently

Why doesn't firestore onWrite trigger get invoked on firebase cloud functions emulator?

穿精又带淫゛_ 提交于 2021-01-27 20:05:04
问题 I have a firestore with a collection called "chats"; I use the firestore emulator to insert a new document and I am expecting the onWrite trigger to get called while I am running index.js locally on my firebase cloud functions emulator (by running firebase emulators:start ), but it never does. I know that the emulator is connected to the right firestore emulator since I can read the data (see below), I just can't get the trigger to be invoked. // My setup: const functions = require('firebase

Python google cloud function deployment failure - Madmom pip package

允我心安 提交于 2021-01-27 20:00:36
问题 I am trying to deploy a Python3.7 Google Cloud Function using the "madmom" python pip package, however specifying madmom==0.16.1 in requirements.txt causes a deployment failure. When I remove madmom from requirements.txt, but leave the other pip packages, the cloud function deploys fine. madmom pypi: https://pypi.org/project/madmom/ madmom github: https://github.com/CPJKU/madmom I a deploying the function from Google Cloud Function's online editor: https://console.cloud.google.com/functions

Cloud Functions for Firebase - Merge multiple PDFs into one via Nodejs/Cloud Function

亡梦爱人 提交于 2021-01-27 18:58:51
问题 I'm running into an issue where I'm trying to combine a bunch of PDFs via a Cloud Function and then have that merged PDF be downloaded to the user's computer. I have a function in my provider that calls the cloud function and passes an array of URLs that point to the pdfs like so: mergePDFs(pdfs) { // Create array of URLs that point to PDFs in Firebase storage let pdfArr = []; for(let key in pdfs) { pdfArr.push(pdfs[key].url); } // Call Firebase Cloud function to merge the PDFs into one this

CORS errors when trying to fetch from new Google Cloud API Gateway

倾然丶 夕夏残阳落幕 提交于 2021-01-27 17:01:52
问题 I was testing out the new API Gateway to secure a cloud function for my React application. So far the process has been much nicer than the previous alternatives, but I am currently getting CORS errors when trying to reach out to my API Gateway from my React app. I am setting the CORS headers correctly in my Cloud Function, but I have no known way of doing the same on the API Gateway endpoint. I am using Postman to test a request to the gateway endpoint and everything is working great, so it

CORS errors when trying to fetch from new Google Cloud API Gateway

这一生的挚爱 提交于 2021-01-27 16:57:20
问题 I was testing out the new API Gateway to secure a cloud function for my React application. So far the process has been much nicer than the previous alternatives, but I am currently getting CORS errors when trying to reach out to my API Gateway from my React app. I am setting the CORS headers correctly in my Cloud Function, but I have no known way of doing the same on the API Gateway endpoint. I am using Postman to test a request to the gateway endpoint and everything is working great, so it