Does Firebase storage offer unique Id's for files? [duplicate]

好久不见. 提交于 2019-12-01 16:03:48

问题


So the realtime database offers me a direct way to reference a node by using its ID. Until now though, I have only seen examples of Firebase storage using the filename to create a reference. What if two files have the same name though? Must I prevent the user from uploading duplicate filenames? The URL is unique but as far as I know you aren't able to create a reference to the file based on it. Is there something I'm missing because this doesn't seem right to me. Thanks for your help.


回答1:


In Firebase Storage it is up to you to determine the file name when uploading the file. There is no built-in method to generate a unique filename for Firebase Storage (like the push() method in the database).

If you have two references to the same path, they will be referring to the same file in Firebase Storage.

If you want globally unique filenames, you'll have to generate those yourself. One way would be to use the Firebase Database's push() method, but you can also use any other GUID-generator for your platform of choice.



来源:https://stackoverflow.com/questions/40747603/does-firebase-storage-offer-unique-ids-for-files

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