小编Son*_*Sol的帖子

GCP:如何向 Firestore 集合上的服务帐户授予角色?

我们可以与服务帐户共享 BigQuery 数据集,我们可以通过为服务帐户分配特定角色来将服务帐户作为成员添加到特定存储桶......使用图形界面。

火力商店怎么样?我们可以与服务帐户共享特定的集合吗?我在网络界面中找不到任何这样的选项..

备注:我无权向服务帐户授予全局权限,但我有权向资源添加成员并授予他们对该特定资源的角色。

谢谢你!

service-accounts firebase-security google-iam google-cloud-firestore

12
推荐指数
1
解决办法
1万
查看次数

React-firestore-hooks 从云 Firestore 中获取数据库记录

我试图弄清楚如何在我的 React 应用程序中使用react-firebase-hooks,以便我可以简化对我的数据库的调用。

我之前的这个尝试版本(在这个问题的帮助下解决了)使用了这个类组件和一个 componentDidMount 函数(它有效):

class Form extends React.Component {
    state = {
      options: [],
    }

    async componentDidMount() {
        // const fsDB = firebase.firestore(); // Don't worry about this line if it comes from your config.
        let options = [];
        await fsDB.collection("abs_for_codes").get().then(function (querySnapshot) {
        querySnapshot.forEach(function(doc) {
            console.log(doc.id, ' => ', doc.data());
            options.push({
                value: doc.data().title.replace(/( )/g, ''),
                label: doc.data().title + ' - ABS ' + doc.id
            });
            });
        });
        this.setState({
            options
        });
    }
Run Code Online (Sandbox Code Playgroud)

我现在正在尝试学习如何使用钩子从使用 react-firebase-hooks 的数据库中获取数据。我目前的尝试是: …

firebase reactjs react-hooks

6
推荐指数
1
解决办法
5363
查看次数

Node.js - 如何获取远程音频文件的持续时间?

我有一个二进制存储桶(在 Firebase Storage 中),并且正在实现一个 node.js 云函数,它获取音频(audio/m4a 或 audio/caf),验证其格式和持续时间,然后将其 uri 与文档关联我的数据库(或者如果音频文件的持续时间无效则删除该音频文件)。

在数据库中创建文档之前,我需要验证音频文件。

为了从存储中下载文件,我使用此功能:

exports.downloadBinaryFileFromUrl = function (fileUrl) {
  /* This function downloads a binary-encoded file from its URL and returns it */
  return axios
    .get(fileUrl, {
      responseType: "arraybuffer",
    })
    .then((res) => Buffer.from(res.data, "binary"))
    .catch((err) => {
      if (err.response) {
        /* 
          The request was made and the server responded with a status code
          that falls out of the range of 2xx
        */
        throw err.response.data;
      } else if (err.request) {
        // Client never …
Run Code Online (Sandbox Code Playgroud)

javascript audio node.js

6
推荐指数
0
解决办法
1849
查看次数

N-Queens 程序使用 LinkedStack 而不是使用递归

我做了很多研究,但所有这些要么是递归,要么不是我目前正在寻找的。我正在尝试使用 LinkedStack 而不是递归创建 N-Queens 程序,LinkedStack 将采用对象 NQueen,而不仅仅是一堆整数。这是我第一次这样做,尽管我了解算法但我不知道如何实现它。就像我如何将一个皇后与堆栈中的最后一个皇后进行比较,以及他们如何存储适合 2 个皇后不会相互攻击的每个位置。我很迷茫,如果可能的话,一些代码如何实现它会很棒。

public class NQueen {
   private static int numSolutions;
   private int col;
   private int row;
   
   public int getCol()
   {
      return col;
   }
   
   public int getRow()
   {
      return row;
   }
   
   public void setCol(int num){
      col= num;
   }
   
   public void setRow(int num) {
      row= num;
   }
   
   public NQueen(int newRow, int newColumn) {
      this.row = newRow;
      this.col = newColumn;
   
   }
   
   public void solve(NQueen Queen, int n ) {
      int current =0;
      LinkedStack<Object> stack = new …
Run Code Online (Sandbox Code Playgroud)

java data-structures

5
推荐指数
0
解决办法
75
查看次数

如何从firestore数据库返回值?

我很难从 Firestore 数据库中返回一个值。我正在尝试从数据库中返回“金额”。设置变量时,我可以在 console.log 中记录“金额”。(请参阅代码)但是当我尝试在函数末尾返回值时,它不返回任何内容。('amount' 未定义 no-undef)我如何返回此值。任何帮助都会很棒。请记住,我对这个话题还是很陌生。

        import firebase from 'firebase/app';
        import 'firebase/firestore';
        import 'firebase/auth';

        export default function checkAmount() {

            let user = firebase.auth().currentUser;

            if (user) {
                let userUID = user.uid
                let docRef = firebase.firestore().collection("users").doc(userUID);

                docRef.get().then((doc) => {
                    if (doc.exists) {
                            let amount = doc.data().amount;
                            if (amount > 0){
                                console.log(amount) /// This does work
                            }
                        } else {
                            console.log("No such document!");
                        }
                    }).catch(function(error) {
                        console.log("Error getting document:", error);
                    });
            }

            return amount /// This **does not** return anything . How …
Run Code Online (Sandbox Code Playgroud)

javascript firebase google-cloud-firestore

2
推荐指数
1
解决办法
2108
查看次数

错误:gcloud 崩溃(WindowsError):[错误 3] 系统找不到指定的路径:u'W:\\'

我正在使用 Google Cloud SDK shell。当输入以下命令时:

gcloud container clusters get-credentials test-cluster
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

ERROR: gcloud crashed (WindowsError): [Error 3] The system cannot find the path specified: u'W:\\'
Run Code Online (Sandbox Code Playgroud)

我不确定为什么会发生这种情况。该命令应该配置kubectl为使用我已经创建的名为“test-cluster”的集群,但它正在尝试查找驱动器 W:,我知道该驱动器不存在。

gcloud google-kubernetes-engine

2
推荐指数
1
解决办法
4195
查看次数

无法使用 PyCharm 中的数据存储模拟器运行 dev_appserver.py

我有一个简单的Python 2.7Google App Engine 应用程序。我将PyCharmProfessional IDE 设置为使用模拟器调试或运行应用程序Datastore,并收到以下错误:

`Cannot use the Cloud Datastore Emulator because the packaged grpcio is incompatible to this system. Please install grpcio using pip`
Run Code Online (Sandbox Code Playgroud)

我尝试使用不做任何更改来安装此软件包( grpciopip

PyCharm 运行以下命令来启动应用程序: /usr/bin/python2.7 /home/netanel/Desktop/google-cloud-sdk/google-cloud-sdk/bin/dev_appserver.py --port 8080 --host localhost --clear_datastore=yes app.yaml --support_datastore_emulator=True

如果我从终端窗口运行此命令,它运行良好

pycharm python-2.7 grpcio

0
推荐指数
1
解决办法
1167
查看次数

Execute the program every 5 minutes with gocron

I need to run my Co program continuously with five minute interval.

I tried using gocron but the program is not giving any output.

func hi() {
    fmt.Println("hi")
}
func main() {
    gocron.Every(5).Minute().Do(hi)
}
Run Code Online (Sandbox Code Playgroud)

I expect this to run and print "hi" at every 5 min interval.

go golang-migrate go-modules

-4
推荐指数
1
解决办法
62
查看次数