对于这些docs,我知道一旦在存储中有了Firebase路径,就可以通过在该路径的getDownloadUrl()
上调用ref
来获取下载URL。我的问题是所有文档建议首先获取下载URL,然后根据这些图像下载文件数据,但是我们可以将该下载URL保留在文件的实时数据库中,因此我们不必调用getDownloadUrl()
每一次?
当前文件上传和下载工作流程->
上传:
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
更好的上传/下载工作流程->
上传:
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是静态的吗?
答案 0 :(得分:1)
下载URL旨在保留。客户每次都调用它是浪费时间。 Firebase示例代码对此进行了说明。