【问题标题】:Firebase web: Storage Location from Download URLFirebase 网站:来自下载 URL 的存储位置
【发布时间】:2017-11-15 18:01:57
【问题描述】:

我正在编写一个需要存储位置的 firebase 函数。 现在我有下载地址:

https://firebasestorage.googleapis.com/v0/b/dxxxxxxxxx.com/o/videosvideo%3A67423?alt=media&token=acxxxxxxxxxxxxxxxxx

有没有办法像这样获取存储位置:

gs://dexxxxxxxxxxxxxx.com/videosvideo:67423

来自给定的下载网址?

【问题讨论】:

  • 当您说“Firebase 函数”时,您的意思是您正在使用 Cloud Functions for Firebase 编写后端代码吗?还是您正在编写客户端代码?您是否只是想将 https 下载 URL 转换为 gs URL?
  • 是的,我正在使用 Cloud Functions for Firebase 编写后端代码。是的,我想将 https 下载 URL 转换为 gs URL。
  • 有办法吗? @道格史蒂文森
  • refFromUrl 有问题吗?好像你在找什么。另见stackoverflow.com/questions/42956250/…

标签: firebase firebase-storage


【解决方案1】:

refFromURl 的描述说它返回一个Reference 并接受:

A URL in the form: 
1) a gs:// URL, for example gs://bucket/files/image.png 
2) a download URL taken from object metadata. 

基于此,我希望以下内容可以正常工作:

const downloadUrl = "https://firestorage.googleapis...";
const gsUrl = firebase.storage().refFromUrl(downloadUrl).toString();

【讨论】:

  • 每当我使用 firebase.storage() 时,我都会收到错误 firebase.storage is not a function。我知道我必须使用谷歌云存储,但为此我也得到 gcs.ref 不是一个函数。无论如何,我只需要来自我从 http url 本身操作的 gs url 的存储桶和文件路径。不过感谢您的反馈。
  • 你好加藤,你知道这个问题的答案吗? stackoverflow.com/questions/44758262/…
猜你喜欢
  • 2018-08-09
  • 2017-06-07
  • 1970-01-01
  • 2019-09-29
  • 1970-01-01
  • 1970-01-01
  • 2021-10-23
  • 2020-07-30
  • 2017-09-23
相关资源
最近更新 更多