Firebase存储结构示例 [英] Firebase storage structure example

查看:84
本文介绍了Firebase存储结构示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解如何上传/下载图像.想知道如何在Firebase控制台中管理此数据的最佳实践吗?

I understand how to upload/download images. Wondering best practice how to manage this data inside firebase console?

我们主要将上传图片/视频并通过我们应用内的私人聊天/群聊在用户之间发送.

We mostly going to upload pictures/videos and send it between users via private chat/group chat within our app.

所以我开始创建这个:

  1. 我应该向用户添加图片吗,例如:

  1. should i add pictures to users e.g:

 /users/<userId>/images/<image-file>  

  • 在聊天组中分享图片怎么样?

  • how would be good to share a picture on chat-group?

     /groups/groupId/images/<image-file> 
    

  • 这是我们的Firebase结构如何处理群组消息

    this is how our firebase structure deals with group messages

      /groups/<groupId>/<messageId>
    

    如果展开messageId,则您会看到消息,userId(写消息的人和时间戳)

    If expanding messageId u see the message,userId(who wrote the message and timestamp)

    建议会受到欢迎

    谢谢.

    推荐答案

    根据我的说法,用户上传的每个图片(或文件)都是用户自己的财产,因此您可以做的是,您的点号1是正确的方法实施.您甚至可以对其应用安全规则.您无需担心体系结构,因为它已经是扁平的.不用担心.

    According to me, every pic (or file) uploaded by user is User's own property, so what you can do is, your point number 1 is the correct way to implement. You can even apply security rules to it. You don't need to worry about architecture, as it is already flat. Nothing to worry about it.

    因此,您将文件上传到用户"文件夹,您将获得指向该文件的链接,并将其存储在Firebase数据库中.我希望你清楚你的观点. 1

    So, you upload file to User's folder and you will get a link to that file and you can store it in Firebase Database. I hope you are clear with your point no. 1

    现在,对于第2点.您的Firebase数据库将具有groups对象,该对象将保存用户所做的聊天.如果要共享图像以进行分组,在这种情况下,也可以将文件上传到Firebase Storage上的文件夹中,只需在群聊中共享指向该图像的链接即可.

    Now, for point number 2. Your Firebase Database will have groups object, that will hold the chats users do. If you want to share the image to group, in this case too, you will upload file to your folder on Firebase Storage, you will just share link to it in Group Chat.

    总体而言,您将文件上传到Firebase存储,在Firebase数据库中存储和共享指向它的链接.

    Overall, You upload files to Firebase Storage, store and share the link to it in Firebase Database.

    希望两点都清楚. 询问是否需要更多许可.

    Hope you are clear with both of your points. Ask if you need more clearance on it.

    这篇关于Firebase存储结构示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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