小编Ros*_*des的帖子

AWS Lambda错误:无法加载gRPC二进制模块,因为它没有为当前系统安装

我在使用无服务器框架的AWS Lambda功能部署时遇到问题.我使用@google-cloud-firestorenpm包需要grpc包.

函数执行抛出错误:

{
  "errorMessage": "Failed to load gRPC binary module because it was not installed for the current system\nExpected directory: node-v48-linux-x64-glibc\nFound: [node-v59-darwin-x64-unknown]\nThis problem can often be fixed by running \"npm rebuild\" on the current system\nOriginal error: Cannot find module '/var/task/node_modules/grpc/src/node/extension_binary/node-v48-linux-x64-glibc/grpc_node.node'",
  "errorType": "Error",
  "stackTrace": [
    "Found: [node-v48-linux-x64-unknown]",
    "This problem can often be fixed by running \"npm rebuild\" on the current system",
    "Original error: Cannot find module '/var/task/node_modules/grpc/src/node/extension_binary/node-v48-linux-x64-glibc/grpc_node.node'",
    "Object.<anonymous> (/var/task/node_modules/grpc/src/grpc_extension.js:44:17)",
    "Module._compile (module.js:570:32)",
    "Object.Module._extensions..js (module.js:579:10)",
    "Module.load (module.js:487:32)",
    "tryModuleLoad …
Run Code Online (Sandbox Code Playgroud)

glibc firebase aws-lambda grpc google-cloud-firestore

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

com.google.firebase.database.DatabaseException

当我开始活动时,它显示错误:

类 com.rcpl.agni.Artist 未定义无参数构造函数。如果您使用 ProGuard,请确保这些构造函数未被剥离。

protected void onStart() {
        super.onStart();
        ref.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                //artistList.clear();
                for(DataSnapshot artistSnapshot : dataSnapshot.getChildren()){
                    Artist artist = artistSnapshot.getValue(Artist.class);
                    Toast.makeText(MainActivity.this, artist.getArtistName(), Toast.LENGTH_SHORT).show();

                }

            }

            @Override
            public void onCancelled(DatabaseError databaseError) {

            }
        });
    }
Run Code Online (Sandbox Code Playgroud)

艺术家.java

package com.rcpl.agni;

/**
 * Created by Dell-pc on 23-01-2018.
 */

public class Artist {
    String artistId;
    String artistName;
    String artistGenre;

    public Artist(String artistId, String artistName, String artistGenre) {
        this.artistId = artistId;
        this.artistName = artistName;
        this.artistGenre = artistGenre; …
Run Code Online (Sandbox Code Playgroud)

android firebase firebase-realtime-database

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


查询firebase for web上的数据

所以我正在建立一个使用firebase的音乐平台,用户可以上传他们的歌曲.当用户登录时,我将他们的数据保存在"usuarios"节点上.当他们上传一首歌时,我会推送到"musicas"节点(usuarios的孩子).这样,我知道是谁上传了这首歌.

但问题是:我想获得所有最近上传的15首歌曲的列表.我怎么做?我的数据结构错了吗?

这是我试过的:

  var musicsRef = firebase.database().ref('usuarios').orderByChild('musicas');
  musicsRef.on('value', function(snapshot) {
  console.log(snapshot.child('musicas');
});
Run Code Online (Sandbox Code Playgroud)

这是我的数据库结构:在此输入图像描述

javascript json firebase firebase-realtime-database

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

有没有办法确定Firebase用户的UID是否有效?

我正在建立一个服务器路由,我希望限制其仅由经过身份验证的用户使用。我计划将带有POST的user.uid发送到此路由,并且我想验证UID是Firebase中存在的UID。我知道我可以在Firebase中手动添加UID并对照此数据进行检查,但是可以查看Firebase身份验证正在跟踪哪些UID?我认为这种方法比对照我自己的列表要好。

这样做的目的是确保不会使用伪造的UID访问这些路由(例如,出于恶意目的)。

firebase firebase-authentication

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

Firebase 实时数据库数据保存策略

我正在研究 Firebase 实时数据库如何存储值。例如:如果数据类型是 number 而不是我存储的数字null,它是分配 1 个字节还是 8 个字节?我在文档中找不到任何关于它的信息。

第二个问题是:我要发送一个geolocation点。在数据库中,我想检查它是否被强制转换为floatgeopoints数据类型。我该如何检查?

nosql firebase firebase-realtime-database

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

如何解决TypeError:functions.https.onCall不是函数?

我有一个我今年早些时候创建的Firebase项目.它使用云功能在实时数据库上运行某些操作.

昨天,我了解了可调用云功能,所以我决定在我的应用程序中尝试它,看看我是否应该更新我现有的功能.我为测试目的创建了一个简单的云函数:

exports.testCall = functions.https.onCall((data, context) =>{
    console.log(context.auth.uid);
    return {response:"This means success"};
});
Run Code Online (Sandbox Code Playgroud)

但是当我尝试部署此函数时,我收到错误:

错误:解析函数触发器时发生错误.

TypeError:functions.https.onCall不是 Object 的函数.(/tmp/fbfn_7614ijhDwX0NY98S/index.js:114:36)在Module.load的Object.Module._extensions..js(module.js:660:10)的Module._compile(module.js:649:30)处( module.js:561:32)在tryModuleLoad(module.js:501:12)的Function.Module._load(module.js:493:3)的Module.require(module.js:593:17)at require( internal/module.js:11:18)atus的/usr/local/lib/node_modules/firebase-tools/lib/triggerParser.js:18:11.(/usr/local/lib/node_modules/firebase-tools/lib/triggerParser.js:32:3)

我知道Callable Cloud Functions已经在最新的Firebase SDK中引入,所以我尝试使用以下方法更新它:

sudo npm install -g firebase-tools
Run Code Online (Sandbox Code Playgroud)

但我还不能部署我的云功能.我也尝试过部分部署,如Firebase文档中所示,但它没有用.文档中有没有我遗漏的东西?

firebase firebase-tools google-cloud-functions firebase-cli

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

未解决的参考:FirebaseVisionLabelDetectorOptions、FirebaseVisionCloudLabel

我一直在使用 Firebase ML Kit 在我的应用中做一些图像标记。一切正常,但今天在更新我的 gradle 依赖项后,我不能再使用一些类,如FirebaseVisionLabelDetectorOptionsFirebaseVisionCloudLabel。它们以红色突出显示,当我将鼠标悬停时,我看到以下消息:

未解决的参考:FirebaseVisionLabelDetectorOptions

这是我的代码:

class ImageActivity : AppCompatActivity() {

    // ... omited code for brevity

    private fun labelImages(image: FirebaseVisionImage) {

        val detector = FirebaseVision.getInstance()
                .visionLabelDetector

        val result = detector.detectInImage(image)
                .addOnSuccessListener { labels ->
                    for (label in labels) {
                        val text = label.label
                        val entityId = label.entityId
                        val confidence = label.confidence
                    }
                }
    }

    private fun labelImagesCloud(image: FirebaseVisionImage) {
        val options = FirebaseVisionCloudDetectorOptions.Builder()
                .setModelType(FirebaseVisionCloudDetectorOptions.LATEST_MODEL)
                .setMaxResults(30)
                .build()

        val detector = FirebaseVision.getInstance()
                .visionCloudLabelDetector

        val …
Run Code Online (Sandbox Code Playgroud)

android kotlin firebase firebase-mlkit

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

如何仅在使用 onUpdate 触发器 Firestore 云功能更改字段时触发操作?

我的事件文档title中有一个名为的字段,其中包含一个布尔值。我在我的文档中设置了 onUpdate firestore 触发器。我想如果我title的更新了,那么我会做一些事情。但如果其他字段被更新,那么我根本不会执行任何操作。怎么做 ?

如果每次文档更新时都调用下面的函数,我没问题,但我只想在title更新时才做一些进一步的操作

exports.dbEventsOnUpdate = functions.firestore
.document('events/{eventId}').onUpdate(async (change,context) => {

        try {        
            const eventID = context.params.eventId

            if (titleIsUpdated) {
               return db.doc(``).set(newData)
            } else {
               // do nothing here
               return null
            }

        } catch(error) {
            console.log(error)
            return null
        }

    })
Run Code Online (Sandbox Code Playgroud)

firebase google-cloud-functions google-cloud-firestore

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

缺少权限或权限不足的Firestore数据库规则

我正在自学firestore,无法找到一种方法仅允许用户更新,删除或仅读取他们添加的集合。

这是我正在使用的结构: Firebase数据库屏幕截图

我使用firebase auth进行用户处理。我将currentUser.uidas 保存在user_id每个集合的数据库中。

这些是我正在使用的规则

service cloud.firestore {
  match /databases/{database}/documents {

    match /tasks{
      allow read, update, delete: if request.auth.uid == resource.data.user_id;
      allow create: if request.auth.uid != null;
    }
  }
Run Code Online (Sandbox Code Playgroud)

当我尝试读取/获取数据时,Missing or insufficient permissions出现错误。

我正在将Web API(JavaScript)用于Firestore。这是我用来读取数据的代码。

function read() {

    db.collection("tasks").get().then((querySnapshot) => {
        querySnapshot.forEach((doc) => {
            var newLI = document.createElement('li');

            newLI.appendChild(document.createTextNode(doc.data().task));

            dataList.appendChild(newLI);

        });
    });

}
Run Code Online (Sandbox Code Playgroud)

rules data-structures firebase google-cloud-firestore

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