What is the purpose behind getDownloadURL of Firebase Storage

南笙酒味 提交于 2020-02-15 09:16:10

问题


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 ->

Upload:

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

Download

 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 ->

Upload:

 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

Download

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

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


回答1:


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.



来源:https://stackoverflow.com/questions/53055190/what-is-the-purpose-behind-getdownloadurl-of-firebase-storage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!