识别用户上传的 Firebase 存储
Identifying Firebase Storage upload by a user
我实现了Firebase Storage
,用户可以上传一些图片到Firebase Storage
。我不想在我的 Android
应用程序中实现用户身份验证功能。
但我想将特定用户上传的图片组合在一起。我的意思是没有用户名,我想确定这些图片是由特定用户或设备上传的。
那么我怎样才能将文件与 phone 中的某种标识符组合在一起,以便稍后对其进行分类。每个 Firebase
用户是否有某种唯一标识符或我可以将其作为我上传的图像的元数据的标识符?
您可以实施 Firebase 身份验证 Anonymous auth
,根据 Firebase
Use Firebase features that require authentication without requiring users to sign in first by creating temporary anonymous accounts. If the user later chooses to sign up, you can upgrade the anonymous account to a regular account, so the user can continue where they left off.
这应该为每个匿名帐户提供一个唯一的上传 User UID
,请参见下图最右边的一列 "User Auth"。
编辑:
看来我错过了你问题的后半部分。
您可以在 "Database" 中创建一个 image_upload JSON 结构,然后 link User UID
到 Storage Location
上传 url。请参阅下面我制作的标题为 Database User.
的示例
数据库用户
一个想法可能是在客户端,当您将图像发送到 firebase 时,您可以在图像文件的开头为它设置一个带有他的 id 的前缀。如果你想 return 他们把他带走那些角色。
这样,在服务器端,如果您想查找特定的用户图像,您只需按存储的文件列表中的前几个字符进行过滤,然后根据需要使用它们:)
我实现了Firebase Storage
,用户可以上传一些图片到Firebase Storage
。我不想在我的 Android
应用程序中实现用户身份验证功能。
但我想将特定用户上传的图片组合在一起。我的意思是没有用户名,我想确定这些图片是由特定用户或设备上传的。
那么我怎样才能将文件与 phone 中的某种标识符组合在一起,以便稍后对其进行分类。每个 Firebase
用户是否有某种唯一标识符或我可以将其作为我上传的图像的元数据的标识符?
您可以实施 Firebase 身份验证 Anonymous auth
,根据 Firebase
Use Firebase features that require authentication without requiring users to sign in first by creating temporary anonymous accounts. If the user later chooses to sign up, you can upgrade the anonymous account to a regular account, so the user can continue where they left off.
这应该为每个匿名帐户提供一个唯一的上传 User UID
,请参见下图最右边的一列 "User Auth"。
编辑:
看来我错过了你问题的后半部分。
您可以在 "Database" 中创建一个 image_upload JSON 结构,然后 link User UID
到 Storage Location
上传 url。请参阅下面我制作的标题为 Database User.
数据库用户
一个想法可能是在客户端,当您将图像发送到 firebase 时,您可以在图像文件的开头为它设置一个带有他的 id 的前缀。如果你想 return 他们把他带走那些角色。
这样,在服务器端,如果您想查找特定的用户图像,您只需按存储的文件列表中的前几个字符进行过滤,然后根据需要使用它们:)