google-cloud-functions

Google Cloud Functions bucket.upload()

﹥>﹥吖頭↗ 提交于 2020-06-14 04:24:49
问题 I'm trying to archive pdf files from remote websites to Google Cloud Storage using a google function triggered by a firebase write. The code below works. However, this function copies the remote file to the bucket root. I'd like to copy the pdf to the pth of the bucket: library-xxxx.appspot.com/Orgs/${params.ukey} . How to do this? exports.copyFiles = functions.database.ref('Orgs/{orgkey}/resources/{restypekey}/{ukey}/linkDesc/en').onWrite(event => { const snapshot = event.data; const params

Google Cloud Functions bucket.upload()

冷暖自知 提交于 2020-06-14 04:24:29
问题 I'm trying to archive pdf files from remote websites to Google Cloud Storage using a google function triggered by a firebase write. The code below works. However, this function copies the remote file to the bucket root. I'd like to copy the pdf to the pth of the bucket: library-xxxx.appspot.com/Orgs/${params.ukey} . How to do this? exports.copyFiles = functions.database.ref('Orgs/{orgkey}/resources/{restypekey}/{ukey}/linkDesc/en').onWrite(event => { const snapshot = event.data; const params

Firebase Functions : How to store simple cookies to remember an authenticated user

谁说胖子不能爱 提交于 2020-06-13 18:03:49
问题 I'm trying to just remeber a user returning to the site and count views, only after 5 minutes. I did this, works when using Firebase Serve , but the cookies are not being stored after deploy. Somewhere up in the app. app.use(cookieSession({ name: 'session', keys: ['utl__key_s1', 'utl__key_s2'] })); Trying to check if session exists and isn't more than 5 min old. function sessionExists(req) { const t = req.session.viewTime; if (t == null) { req.session.viewTime = + new Date(); return false; }

Firebase Functions : How to store simple cookies to remember an authenticated user

好久不见. 提交于 2020-06-13 18:02:57
问题 I'm trying to just remeber a user returning to the site and count views, only after 5 minutes. I did this, works when using Firebase Serve , but the cookies are not being stored after deploy. Somewhere up in the app. app.use(cookieSession({ name: 'session', keys: ['utl__key_s1', 'utl__key_s2'] })); Trying to check if session exists and isn't more than 5 min old. function sessionExists(req) { const t = req.session.viewTime; if (t == null) { req.session.viewTime = + new Date(); return false; }

How to debug firebase cloud functions in WebStorm?

╄→尐↘猪︶ㄣ 提交于 2020-06-12 20:33:10
问题 I've started a firebase cloud functions project and want to know how i can get the debugging within the WebStorm IDE running? I've read that i can archive my goal using @google-cloud/functions-emulator. Therefore I installed it and followed this documentation After running functions inspect myFunction , I got following output. Warning: You're using Node.js v10.6.0 but the Google Cloud Functions runtime is only available in Node.js 6 and Node.js 8. Therefore, results from running emulated

Securely calling a Google Cloud Function via a Google Apps Script

不羁的心 提交于 2020-06-12 09:11:57
问题 How can I securely call a Google Cloud Function via a Google Apps Script? ✅ I have a Google Cloud Function, which I can access at https://MY_REGION-MY_PROJECT.cloudfunctions.net/MY_FUNCTION , and which I would like to allow certain users to invoke via an Apps Script. ✅ To secure the Cloud Function, I have set Cloud Function Invoker to only include known email (e.g. USER@COMPANY.com , where this is a valid Google email). ✅ I am able to successfully invoke the Cloud Function via curl, while

Securely calling a Google Cloud Function via a Google Apps Script

大憨熊 提交于 2020-06-12 09:11:02
问题 How can I securely call a Google Cloud Function via a Google Apps Script? ✅ I have a Google Cloud Function, which I can access at https://MY_REGION-MY_PROJECT.cloudfunctions.net/MY_FUNCTION , and which I would like to allow certain users to invoke via an Apps Script. ✅ To secure the Cloud Function, I have set Cloud Function Invoker to only include known email (e.g. USER@COMPANY.com , where this is a valid Google email). ✅ I am able to successfully invoke the Cloud Function via curl, while

Firestore query costs

ε祈祈猫儿з 提交于 2020-06-12 06:12:19
问题 On Firestore I have a social app that stores each user as a document, and queries based on users within a certain distance. If a user launched the app and had 1,000 users within 50 miles for example, would I be charged for 1000 reads for downloading all nearby profiles? That seems like it would be hyper expensive if I got charged that much every time a user queried nearby users. Is there a cheaper way to do this? 回答1: As far as I know, if your query returns 1 document, you'll be charged 1

Firebase function deploying, but not showing up in console

蓝咒 提交于 2020-06-12 05:48:26
问题 This question is essentially the same as question 44799104, only that I provide my index.js (and the only answer there was not helpful, as I do include 'exports'). In short, I have deployed my function successfully, but it does not show in the console. Where am I going wrong? Here is my index.js: const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(functions.config().firebase); var delayInMilliseconds = 5000; exports.copyRoom= functions

Firebase - Targeting Specific Firestore Document Field with Cloud Functions

╄→гoц情女王★ 提交于 2020-06-10 09:16:37
问题 When using Cloud Functions with the Firebase Realtime Database you are able to target a specific field with a cloud function. For example, given this JSON structure, I could target when user1's email field changed with a ('/user/{userId}/email').onUpdate cloud function. { "user": { "user1": { "name": "John Doe", "phone": "555-5555", "email": "john@gmail.com" } } } Now with Firestore it seems that I can't target a specific field and can only target documents. If this is the case a Firestore