Firebase存储是否为文件提供了唯一的ID? [英] Does Firebase storage offer unique Id's for files?
问题描述
在Firebase存储中,上传文件时由您决定文件名。没有内置的方法可为Firebase存储生成唯一的文件名(例如数据库中的
push()
方法)。 如果您有两个对同一路径的引用,它们将引用Firebase存储中的同一文件。
如果您想要全球唯一的文件名,必须自己生成这些。一种方法是使用Firebase数据库的 push()
方法,但也可以使用任何其他GUID生成器为您选择的平台。
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.
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.
这篇关于Firebase存储是否为文件提供了唯一的ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!