Firebase Storage getDownloadUrl的令牌有效性 [英] Firebase Storage getDownloadUrl's token validity

查看:86
本文介绍了Firebase Storage getDownloadUrl的令牌有效性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用FirebaseStorage的getDownloadUrl时,我对url(& token =)中的令牌"有疑问.

I have a question regarding the "token" in the url(&token=) when using getDownloadUrl of FirebaseStorage.

https://firebasestorage.googleapis.com/v0/b/someapplication.appspot.com/o/images%2Fsample.png?alt=media&token=123456

从文档中说,它返回一个寿命长"的下载网址 https://firebase.google.com/docs/reference/js /firebase.storage.Reference#getDownloadURL

From docs, it says that it returns a "long lived" download url https://firebase.google.com/docs/reference/js/firebase.storage.Reference#getDownloadURL

问题是,我将downloadUrl保存在FirebaseDatabase中,例如

Problem is, im saving the downloadUrl in FirebaseDatabase like

-chatroom
  - c1
    - m1
      -message: "Sent a photo"
      -photoUrl: downloadUrl here

据我了解,这不是生命周期令牌,因此在某些时间令牌将无效.因此,例如,当我在ImageView中显示此网址时,它不会加载图片.

From what i understand it is not a lifetime token so at some point in time the token will not be valid. So when I display this url in an ImageView for example, it will not load the image.

Picasso.with(context)
  .load(downloadUrl)
  .into(imageView)

我知道我可以在firebase中使用类似的东西来生成一个新的东西.

I do understand I can use something like this in firebase to generate a new one.

StorageReference sr = getReferenceFromUrl(downloadUrl)
//pseudo-code
sr.getDownloadUrl().addOnSuccessListener((Uri newUri) => {
  Picasso.with(context)
  .load(newUri)
  .into(imageView)
});

但是!此过程的开销是始终在该过程中获取新的下载URL.

BUT! this process has an overhead of always getting a new download url in the process.

再说一次,令牌将生存多长时间?另外,如果它不是生命周期令牌,那么我们应该如何正确存储下载URL?

So again, how long will the token lived? Also if it is not a lifetime token, how should we store the download url properly?

推荐答案

Firebase存储令牌不会过期.

它们可能会从Firebase控制台中撤消,这会使基于它们的URL失效.

They may be revoked from the Firebase Console, which would invalidate URLs based on them.

这篇关于Firebase Storage getDownloadUrl的令牌有效性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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