firebase-admin

Firebase Storage upload php

一世执手 提交于 2019-12-06 16:10:35
问题 I'm currently trying to upload to the Firebase Cloud Storage using php, but running into an issue. I have a form in html, that takes the uploaded file (in my case an image), and passes it to a php file. This image is very small, 12.8kB, and a JPEG image. The php file takes the image, and tries to upload it to the storage. My current php code is roughly: $storage = new StorageClient(['projectId' => '<my_project_id> ']); $bucket = $storage->bucket('images'); $bucket->upload($_FILES[

Firebase Admin SDK to download/retrieve files on Google Cloud Storage

我的梦境 提交于 2019-12-06 15:15:27
I'm trying to download some images that I have uploaded to my Google Cloud Storage (aka into buckets). I'm unable to use the .ref() method on any of my const storage or const bucket because they are part of the admin SDK. The admin.storage has only the method .bucket() ( https://firebase.google.com/docs/reference/admin/node/admin.storage.Storage ). I'm able to access the buckets. bucket.getFiles() works, and the result comes out to be an Array of Files objects with a ton of metadata (like file name, bucket owner, etc.). How can I get my images from the cloud storage and insert them into html

Firebase rules allowing write when they shouldn't be

孤街浪徒 提交于 2019-12-06 12:10:43
I have the following database entry: "companies: 8": I have the following database rules, which do not allow a simulated write of "companies: 8" to the database. { "rules": { ".read": "auth != null", ".write": "auth != null", "companies": { ".validate": "(data.exists() && (newData.val() === data.val() + 1)) || (!data.exists() && newData.val() == 0)" } } } However, when I try to write "companies: 20" to the database with the Firebase Python SDK, which also is not allowed under these rules, it works: In [1]: import firebase_admin In [2]: from firebase_admin import credentials, db In [3]: cred =

Firebase-admin won't write to database, gives no errors

允我心安 提交于 2019-12-06 11:22:11
问题 Firebase admin isn't writing to the database. I am instantiating the database: var db = admin.database(); Then setting up a reference to the table I want: var systemsRef = db.ref("systems/"); I then have a function to check if the 'system', (an encrypted hardware id), exists. function isSystemRegistered(id){ var isTrue; systemsRef.once('value', function(snapshot) { isTrue = (snapshot.hasChild(id))? true : false; }); return isTrue; } Which, as of yet returns false ; which is true , because it

Firebase Admin Java SDK not doing any operation

我的未来我决定 提交于 2019-12-06 09:23:39
I've setup the firebase admin SDK using this guide So I'm initializing it in the following way. InputStream refreshToken = new ClassPathResource(CONFIG_FILE).getInputStream(); FirebaseOptions options = new FirebaseOptions.Builder() .setCredential(FirebaseCredentials.fromRefreshToken(refreshToken)) .setDatabaseUrl("https://<project-id>.firebaseio.com/") .build(); FirebaseApp.initializeApp(options); I got no errors to this point, everything seems fine. However, I'm unable to do any operations. Calling the methods does nothing. Eg: FirebaseDatabase.getInstance() .getReference()

How to use Firebase Admin SDK in Flutter?

无人久伴 提交于 2019-12-06 04:10:13
I'm creating a app where I should be able of managing users access. The admin should have permissions of creating, deleting and editing users accounts. I'm using firebase for creating users account. Right now individually users can creating, editing and delete their accounts, but the problem is that the admin should do that, and not just the users. import 'dart:async'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/services.dart'; import 'package:google_sign_in/google_sign_in.dart'; class UserLoader { final FirebaseAuth _auth = FirebaseAuth.instance; final

Im having trouble while serving or deploying Firebase Hosting Functions

谁说胖子不能爱 提交于 2019-12-06 03:16:02
问题 The Cloud Functions emulator requires the module "firebase-admin" to be installed. This package is in your package.json, but it's not available. You probably need to run "npm install" in your functions directory. I was running well my project till i was hit with that issue. Any help, please do tell. Thanks. {Below is the image of what i am getting} 回答1: This is a bug in firebase-tools versions 6.9.0 and 6.9.1 . The solution is to downgrade to 6.8.0 for now: npm install -g firebase-tools@6.8.0

How to access multiple Realtime Database instances in Cloud Functions for Firebase

社会主义新天地 提交于 2019-12-06 01:14:41
问题 I'm using multiple databases in a Firebase project. Cloud functions for the main (default) database work great, however, I cannot make them work for a secondary database. For example I want to make a read request on a node with admin privileges: //this works admin.database().ref(nodePath).once('value')... This works in the main database, however, if I want to execute the command on another database, it doesn't work: //this doesn't work admin.database(secondaryDatabaseUrl).ref(nodePath).once(

Cloud Functions: How to copy Firestore Collection to a new document?

自古美人都是妖i 提交于 2019-12-06 00:33:53
问题 I'd like to make a copy of a collection in Firestore upon an event using Cloud Functions I already have this code that iterates over the collection and copies each document const firestore = admin.firestore() firestore.collection("products").get().then(query => { query.forEach (function(doc){ var promise = firestore.collection(uid).doc(doc.data().barcode).set(doc.data()); }); }); is there a shorter version? to just copy the whole collection at once? 回答1: Currently, no. Looping through each

Quota exceeded when updating users with Firebase Admin SDK - how can I request more?

蹲街弑〆低调 提交于 2019-12-05 18:58:15
We try to update many users in our multitenant setup, when a whole tenant needs to be enabled/disabled. With this, we sometimes run into QUOTA_EXCEEDED errors, especially for large tenants with many users. I have asked how to do this better here: Disable many users at once As there are currently no bulk operations to update users with the Firebase Admin SDK , how can I request a quota raise? I do not see an enable/disable users in the Firebase Authentication Limits The error message does not indicate what has to be changed. It only says Exceeded quota for updating account information. I do not