google-cloud-functions

Google Cloud Functions: Return valid JSON

自作多情 提交于 2020-05-14 20:16:57
问题 I´m trying to call a Google Cloud Function from my Flutter App using the cloud_functions package. This is my Cloud Function: export const helloWorld = functions.region('europe-west1').https.onRequest((request, response) => { response.status(200).json({ message: "Hello World!" }); }); And this is my flutter method that calls this function: try { final dynamic resp = await CloudFunctions.instance.call( functionName: "helloWorld" ); print(resp); } on CloudFunctionsException catch (e) { ... }

Google Cloud Functions: Return valid JSON

梦想与她 提交于 2020-05-14 20:16:05
问题 I´m trying to call a Google Cloud Function from my Flutter App using the cloud_functions package. This is my Cloud Function: export const helloWorld = functions.region('europe-west1').https.onRequest((request, response) => { response.status(200).json({ message: "Hello World!" }); }); And this is my flutter method that calls this function: try { final dynamic resp = await CloudFunctions.instance.call( functionName: "helloWorld" ); print(resp); } on CloudFunctionsException catch (e) { ... }

How to get the uid of the authenticated Firebase user in a Cloud Functions storage trigger

做~自己de王妃 提交于 2020-05-14 10:25:13
问题 Background: I'm using Firebase Cloud Functions, the new Firestore Database, and storage bucket with an Android client. What I want to accomplish: When a user uploads a picture to a storage bucket, I want to use cloud functions to get the file path/link to the image location in the storage bucket and store this string as a new document under a new collection called "pictures" under the currently logged in user's document in Firestore. That way, I can see the images each user has uploaded

How to get the uid of the authenticated Firebase user in a Cloud Functions storage trigger

夙愿已清 提交于 2020-05-14 10:22:48
问题 Background: I'm using Firebase Cloud Functions, the new Firestore Database, and storage bucket with an Android client. What I want to accomplish: When a user uploads a picture to a storage bucket, I want to use cloud functions to get the file path/link to the image location in the storage bucket and store this string as a new document under a new collection called "pictures" under the currently logged in user's document in Firestore. That way, I can see the images each user has uploaded

Getting user info from request to Cloud Function in Firebase

旧街凉风 提交于 2020-05-13 05:14:02
问题 I'd like to be able to get user information for a Cloud Function that gets called in Firebase. I have something like this, which is being called after the user signs into the app: exports.myFunction = functions.https.onRequest((req, res) => { ... } And I need to get the uid of the signed-in user that made the request. Any advice or comments please? 回答1: Information about the user that makes the request is not automatically passed along with HTTPS functions calls. You can either pass the ID

Getting user info from request to Cloud Function in Firebase

*爱你&永不变心* 提交于 2020-05-13 05:11:20
问题 I'd like to be able to get user information for a Cloud Function that gets called in Firebase. I have something like this, which is being called after the user signs into the app: exports.myFunction = functions.https.onRequest((req, res) => { ... } And I need to get the uid of the signed-in user that made the request. Any advice or comments please? 回答1: Information about the user that makes the request is not automatically passed along with HTTPS functions calls. You can either pass the ID

How Firebase Cloud functions handle HTTP post method?

十年热恋 提交于 2020-05-12 11:07:24
问题 I have created Firebase Cloud Functions app, I created function with https.onRequest . and get data with req.body but there is not data there. Can Firebase Cloud Functions can handle HTTP POST method? This is my sample code:- var functions = require('firebase-functions'); exports.testPost = functions.https.onRequest((req, res) => { console.log(req.body); }); I tested by postman with POST method but didn't show result in Firebase log. 回答1: Functions built on Firebase can also use Express.js

Firestore cloud function to recursively update subcollection/collectionGroup

梦想的初衷 提交于 2020-05-11 23:53:48
问题 I have this cloud function: import pLimit from "p-limit"; const syncNotificationsAvatar = async ( userId: string, change: Change<DocumentSnapshot> ) => { if (!change.before.get("published") || !change.after.exists) { return; } const before: Profile = change.before.data() as any; const after: Profile = change.after.data() as any; const keysToCompare: (keyof Profile)[] = ["avatar"]; if ( arraysEqual( keysToCompare.map((k) => before[k]), keysToCompare.map((k) => after[k]) ) ) { return; } const

Firestore cloud function to recursively update subcollection/collectionGroup

☆樱花仙子☆ 提交于 2020-05-11 23:49:44
问题 I have this cloud function: import pLimit from "p-limit"; const syncNotificationsAvatar = async ( userId: string, change: Change<DocumentSnapshot> ) => { if (!change.before.get("published") || !change.after.exists) { return; } const before: Profile = change.before.data() as any; const after: Profile = change.after.data() as any; const keysToCompare: (keyof Profile)[] = ["avatar"]; if ( arraysEqual( keysToCompare.map((k) => before[k]), keysToCompare.map((k) => after[k]) ) ) { return; } const

Firestore cloud function to recursively update subcollection/collectionGroup

自闭症网瘾萝莉.ら 提交于 2020-05-11 23:49:23
问题 I have this cloud function: import pLimit from "p-limit"; const syncNotificationsAvatar = async ( userId: string, change: Change<DocumentSnapshot> ) => { if (!change.before.get("published") || !change.after.exists) { return; } const before: Profile = change.before.data() as any; const after: Profile = change.after.data() as any; const keysToCompare: (keyof Profile)[] = ["avatar"]; if ( arraysEqual( keysToCompare.map((k) => before[k]), keysToCompare.map((k) => after[k]) ) ) { return; } const