Firebase存储是否为文件提供了唯一的ID? [英] Does Firebase storage offer unique Id's for files?

查看:119
本文介绍了Firebase存储是否为文件提供了唯一的ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以实时数据库为我提供了一个直接的方式来使用它的ID来引用一个节点。到目前为止,我只看到了使用文件名创建引用的Firebase存储示例。如果两个文件具有相同的名称呢?我必须阻止用户上传重复的文件名吗?该URL是唯一的,但据我所知,你不能创建一个基于它的文件的引用。有什么我失踪,因为这似乎不正确的我。感谢您的帮助。

解决方案

在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆