Get Download URL from file uploaded with Cloud Functions for Firebase

后端 未结 23 1855
春和景丽
春和景丽 2020-11-22 01:19

After uploading a file in Firebase Storage with Functions for Firebase, I\'d like to get the download url of the file.

I have this :

...

return buck         


        
23条回答
  •  死守一世寂寞
    2020-11-22 02:13

    One method I'm using with success is to set a UUID v4 value to a key named firebaseStorageDownloadTokens in the metadata of the file after it finishes uploading and then assemble the download URL myself following the structure Firebase uses to generate these URLs, eg:

    https://firebasestorage.googleapis.com/v0/b/[BUCKET_NAME]/o/[FILE_PATH]?alt=media&token=[THE_TOKEN_YOU_CREATED]
    

    I don't know how much "safe" is to use this method (given that Firebase could change how it generates the download URLs in the future ) but it is easy to implement.

提交回复
热议问题