且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何设置Firebase存储规则以检查Firebase数据库中的参数?

更新时间:2023-12-01 22:15:04

一种可能性是编写一个Cloud Function,用作图像请求的处理器".除了直接访问图像,我们还可以公开一个Cloud Function作为图像的代理.然后,Cloud Function可以使用当前日期和请求者身份以及存储在数据库中的数据来评估表达式.如果允许,则Cloud Function可以返回已授权Cloud Function访问的原始数据.

One possibility is to write a Cloud Function that serves as the "processor" for image requests. Rather than access the image directly, we could expose a Cloud Function as the proxy for the image. The Cloud Function could then evaluate an expression using current date and requestor identity in conjunction with the data stored in the database. If allowed, then the Cloud Function could return the raw data which the Cloud Function is authorized to access.

作为Cloud Function返回数据的替代方法,Cloud Function可以返回可用于访问数据的URL.这可能是来自Google Cloud Storage的签名URL 仅授予该URL访问者所有,并且有时间限制,以防止过期后进行访问.

As an alternative to the Cloud Function returning the data, the Cloud Function could return a URL that could be used to access the data. This could be a signed url from Google Cloud Storage that would give only the possessor of that URL access and would also be time bound to prevent access after expiration.