【问题标题】:Get permanently publicly downloadable URL of a file in cloud storage from firebase functions [duplicate]从firebase函数获取云存储中文件的永久可公开下载URL [重复]
【发布时间】:2021-12-24 18:56:38
【问题描述】:

我想通过 firebase 函数获取 Google Cloud 存储中文件的可匿名下载链接。

从 JS SDK,您可以通过以下方式获得永久可下载的链接

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

【问题讨论】:

标签: firebase google-cloud-storage firebase-storage


【解决方案1】:

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

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

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

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

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

【讨论】:

  • 我看到了情况。非常感谢您终止了我在 Google 和 GitHub 问题上的无休止搜索。我会从 JS SDK 处理。
  • 嗨,Doug - 仅公开 Cloud Storage 存储桶并使用格式 (storage.googleapis.com/${bucket.name}/${file.name}) 直接引用公共 URL 有什么问题吗?对于不需要安全授权的公共数据,这似乎是最简单的解决方案,但我很好奇是否有理由不使用它。
猜你喜欢
  • 2020-10-22
  • 2020-11-23
  • 2018-12-08
  • 2018-07-04
  • 1970-01-01
  • 2021-04-03
  • 1970-01-01
  • 2017-07-08
  • 2019-08-08
相关资源
最近更新 更多