从 firebase 函数获取云存储中文件的永久公开可下载 URL

Get permanently publicly downloadable URL of a file in cloud storage from firebase functions

我想通过 firebase 函数在 Google 云存储中获取可匿名下载的文件 link。

从 JS SDK,您可以通过

获得永久可下载的link
const ref = storageRef.child('images/stars.jpg');
const url = await ref.getDownloadURL()

[1]。是否可以使用 firebase-adminfirebase/storage 从函数中做同样的事情?我只找到一个签名的 url[2],有效期最长为 7 天。

[1] https://firebase.google.com/docs/storage/web/download-files
[2] https://cloud.google.com/storage/docs/access-control/signed-urls

没有对此的 SDK 支持。有一个开放的功能请求:

https://github.com/firebase/firebase-admin-node/issues/1352

其中引用了 Google Cloud SDK 中的一个冗长问题(firebase-admin 只是一个包装器):

https://github.com/googleapis/nodejs-storage/issues/697

通读完所有这些内容后,您就会明白这是一个长期的 运行 功能请求,可能不会很快得到支持。