Understanding Firebase Storage tokens

后端 未结 2 2046
既然无缘
既然无缘 2021-01-07 22:30

I\'m trying to understand how tokens work in Firebase Storage.

Whenever my web app uploads an image to FS it adds a token to its public url. The problem is whenever

相关标签:
2条回答
  • 2021-01-07 22:58

    Tokens are unique for a particular version of an upload. If you overwrite the file with new content, then a new token will be generated with a new unguessable url.

    So in other words, tokens are unique for a particular blob -- they are not unique per storage location. We did this as an increased measure of security to ensure that developers and end users did not accidentally expose data they did not intend.

    You can, however, translate the storage location ("gs://mybucket/myfile.png") into a download url using our js SDK. That way, you can pass around the gs uri if you wish and translate it to a full URL once you want to place it into an image.

    See: https://firebase.google.com/docs/reference/js/firebase.storage.Reference.html#getDownloadURL

    0 讨论(0)
  • 2021-01-07 23:16

    For public file upload: If you upload files in firebase functions you'll need to call makePublic() on the reference object in order to make it accessible without having a valid token.

    0 讨论(0)
提交回复
热议问题