【问题标题】:Do wildcards exist for Firebase Fuctions on Storage?Firebase 存储功能是否存在通配符?
【发布时间】:2018-04-22 21:29:53
【问题描述】:

我一直在成功使用 Firebase 函数对我上传到 Firebase 存储的文件执行操作。

我目前想要做的是使用通配符访问我将数据推送到其中的文件夹,其实现方法与实时数据库 + Firestore 的工作方式相同。但是,每当我尝试访问这些参数时,它们都会专门返回 null

这不可能吗?

这是我的代码示例:

  exports.generateThumbnail = functions.storage.object('user-photos/{userId}/{publicOrPrivate}').onChange(event => {
    const privateOrPublic = event.params.publicOrPrivate;
    const isPrivate = (event.params.publicOrPrivate == "private");
    const userId = event.params.userId;

    console.log("user id and publicOrPrivate are", userId, privateOrPublic);
    //"user id and publicOrPrivate are undefined undefined"
    }

谢谢!

【问题讨论】:

  • 基于this documentation,可以从事件中获取bucket中的完整文件路径:event.object.name。然后,您需要提取所需的路径段。你试过吗?
  • 谢谢,但我有。我希望有一种更优雅的方式来做到这一点。我不喜欢将字符串解析成数组,感觉有点 hacky :

标签: node.js firebase firebase-storage google-cloud-functions


【解决方案1】:

Cloud Storage 触发器目前不支持通配符。您必须检查更改的文件的路径以确定是否要对其执行任何操作。

【讨论】:

  • 2019年8月还是这样吗?
猜你喜欢
  • 2019-05-22
  • 2018-08-03
  • 1970-01-01
  • 2020-11-22
  • 2021-11-25
  • 2021-09-08
  • 2020-10-04
  • 1970-01-01
相关资源
最近更新 更多