Firebase Storage的getDownloadURL的目的是什么 [英] What is the purpose behind getDownloadURL of Firebase Storage

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

问题描述

根据这些文档,我知道一旦存储了Firebase路径,就可以通过在该路径的ref上调用getDownloadUrl()来获取下载URL.我的问题是所有文档建议首先获取下载URL,然后根据这些图像下载文件数据,但是我们可以将该下载URL保留在文件的实时数据库中,因此我们不必每次都调用getDownloadUrl() ?

Per these docs, I understand once we have the firebase path in storage, we can get the download url by calling getDownloadUrl() on this path's ref. My question is all the docs suggest to get the download url first then download file data based on these image, but can we persist this download url in our realtime db for the file, so we don't have to call getDownloadUrl() each time?

当前文件上传和下载工作流程->

Current file upload and download workflow ->

上传:

 1. upload file to storage in specific path.
 2. store path in realtime DB to persist for future downloading purposes

下载

 1. get object from realtime DB and retrieve storage path
 2. get storage object
 3. get url from getDownloadUrl() on that object
 4. download data from url

更好的上传/下载工作流程->

Better upload/download workflow ->

上传:

 1. upload file to storage in specific path.
 2. get download url from storage object 
 3. store download path in realtime DB to persist for future downloading purposes

下载

 1. get object from realtime DB 
 2. get download url stored in object
 3. download data from download url

getDownloadUrl()到底是做什么的,给定的URL是静态的吗?

What is getDownloadUrl() doing under the hood and is the given url static?

推荐答案

下载URL旨在保持不变.客户每次都打电话来浪费时间.在Firebase示例代码中始终如一地说明了这一点.

The download URL is meant to be persisted. It's a waste of time for clients to call it every time. This is illustrated consistently in Firebase sample code.

这篇关于Firebase Storage的getDownloadURL的目的是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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