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