google-cloud-functions

How to make functions work with Firestore?

十年热恋 提交于 2021-01-27 05:24:36
问题 functions/index.js: const functions = require('firebase-functions') const admin = require('firebase-admin') admin.initializeApp(functions.config().firebase) const db = admin.database().ref() exports.app = functions.https.onRequest((req, res) => { // do whatever here... db.child('something').once('value').then(snap => console.log(snap.key)) }) Above works for Firebase. I'm interested in making this example work from functions. Something like this but working: const functions = require(

How to parse multipart/form-data on firebase cloud functions?

安稳与你 提交于 2021-01-27 05:21:47
问题 I've been trying to post a multipart/form-data object with text and an image file to one of my cloud functions, according to the documents here: https://cloud.google.com/functions/docs/writing/http#multipart_data_and_file_uploads I've kept my cloud function almost entirely the same as the example, except I've wrapped it in a CORS response. It seems though, that no matter what, busboy's 'field' and 'file' events never fire, and when I print the request body's toString method, I get some of the

Why Puppeteer needs --no-sandbox to launch Chrome in Cloud Functions

╄→гoц情女王★ 提交于 2021-01-27 04:23:13
问题 When I run Puppeteer on Cloud Functions with Node 8, I get this error. Error: Failed to launch chrome! [1205/063825.588245:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180. Launching Puppeteer with browser = await puppeteer.launch({ args: ['--no-sandbox'], headless: true }) solves the issue. I have searched on the internet and could not find any reason why is this necessary? Why does Headless Chrome run as root in the

Delete all firebase functions

眉间皱痕 提交于 2021-01-27 02:40:44
问题 I have a firebase project with multiple functions deployed. Is it possible to remove all the functions in a single go through the CLI? I tried the command firebase functions:delete --region us-central1 and the error output was Error: Must supply at least function or group name. As of right now, I deleted all of them specifying each of their names as such: firebase functions:delete function1 function2 ...functionN but this is very cumbersome. The version of firebase-tools installed is v4.0.0

Delete all firebase functions

自闭症网瘾萝莉.ら 提交于 2021-01-27 02:39:33
问题 I have a firebase project with multiple functions deployed. Is it possible to remove all the functions in a single go through the CLI? I tried the command firebase functions:delete --region us-central1 and the error output was Error: Must supply at least function or group name. As of right now, I deleted all of them specifying each of their names as such: firebase functions:delete function1 function2 ...functionN but this is very cumbersome. The version of firebase-tools installed is v4.0.0

Delete all firebase functions

我与影子孤独终老i 提交于 2021-01-27 02:39:05
问题 I have a firebase project with multiple functions deployed. Is it possible to remove all the functions in a single go through the CLI? I tried the command firebase functions:delete --region us-central1 and the error output was Error: Must supply at least function or group name. As of right now, I deleted all of them specifying each of their names as such: firebase functions:delete function1 function2 ...functionN but this is very cumbersome. The version of firebase-tools installed is v4.0.0

Which service account is used when running Firebase Cloud Functions?

只愿长相守 提交于 2021-01-26 10:29:31
问题 I'm trying to create a schedule Cloud Function exporting my Firestore database to create backups. The code is running fine when serving on my local machine (which uses my personal user account with owner role) but failes once deployed. I already found out that I need to add the 'Storage Admin' and 'Datastore Import Export Admin' to the service account used when running the cloud function, but I can't figure out which service account is used for the functions. Does anyone know which service

Send a bucket file to FTP server using pysftp

心不动则不痛 提交于 2021-01-25 07:13:13
问题 I'm trying to send a file from a bucket to a FTP server using pysftp. For this I'm using Google cloud functions with python 3.7 I have tried with many different ways, but always with an error. 1.- Downloading the file as string: in this example, to avoiding error with the file content, I will create a file which contains "test string" instead of using what is inside of the bucket file def sftp_handler(): myHostname = "hotsname.com" myUsername = "username" myPassword = "pass" try: keydata = b"

How to correctly execute a axios POST request within a firebase cloud function

与世无争的帅哥 提交于 2021-01-25 05:25:09
问题 I'm currently working on an app that publishes a post to facebook on call of the below firebase cloud function. Problem now is that the request throws back an error 408: Error - Post on Facebook { Error: Request failed with status code 408 at createError (/user_code/node_modules/axios/lib/core/createError.js:16:15) at settle (/user_code/node_modules/axios/lib/core/settle.js:18:12) at IncomingMessage.handleStreamEnd (/user_code/node_modules/axios/lib/adapters/http.js:201:11) at emitNone

Google Cloud Functions Build failed: function.js does not exist; Error ID: 7485c5b6

岁酱吖の 提交于 2021-01-24 20:23:21
问题 I generated a demo express server using these steps: npm install -g express-generator express myExpressApp --view pug Needless to say, the app runs fine on my local machine ( npm start ) I then pushed the code to Cloud Source Repositories Then deploy to Google Cloud Functions through their web app What am I missing? Source codes of my generated demo app: /myExpressApp/app.js var createError = require('http-errors'); var express = require('express'); var path = require('path'); var