是否可以将 Firebase 函数的范围限定为存储桶内的文件夹?

编程入门 行业动态 更新时间:2024-10-10 19:16:27
本文介绍了是否可以将 Firebase 函数的范围限定为存储桶内的文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经成功测试了 Firebase 存储功能.但是,我没有看到任何提示如何仅在将文件添加到我的存储桶内的文件夹中时调用该函数.我看到的关于确定函数范围的唯一提示是针对不同的存储桶这里.

I have tested Firebase functions for storage successfully. However, I havn't seen anywhere a hint how to only invoke the function when a file is added into a folder inside my bucket. The only hint I have seen about scoping the function is for different buckets here.

是否可以将函数范围限定为我的存储桶内的文件夹,如果可以,如何?或者我需要多个存储桶而不是文件夹来分隔不同的任务.

Is it possible to scope the function to a folder inside my bucket , if yes how? Or would I need to have multiple buckets instead of folders to separate different tasks.

推荐答案

firebaser here

目前无法仅针对 Cloud Storage 中特定文件夹中的写入触发 Cloud Functions.如果您想将触发限制在项目中的文件子集,则将它们放在单独的存储桶中是目前实现此目的的唯一方法.

There is currently no way to trigger Cloud Functions only for writes in a specific folder in Cloud Storage. If you want to limit the triggering to a subset of the files in your project, putting them in a separate bucket is currently the only way to accomplish that.

作为一种解决方法,您可以将有关图像的元数据写入支持的数据库(实时数据库或 Cloud Firestore),并使用它来触发转换文件的 Cloud Function.这是我通常做的事情,因为它还允许我以可以查询的格式捕获元数据.

As a workaround, you can write metadata about the image to a supported database (Realtime Database or Cloud Firestore), and use that to trigger a Cloud Function that transforms the file. This is what I usually do, as it also allows me to capture the metadata in a format that can be queried.

更多推荐

是否可以将 Firebase 函数的范围限定为存储桶内的文件夹?

本文发布于:2023-11-12 10:06:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581180.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件夹   函数   Firebase

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!