是否可以将 Firebase 函数的范围限定为存储桶内的文件夹? [英] Is it possible to scope Firebase functions to a folder inside a storage bucket?

查看:23
本文介绍了是否可以将 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 函数的范围限定为存储桶内的文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆