Firebase storage structure example

眉间皱痕 提交于 2020-02-24 11:13:29

问题


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.

So I started to create this:

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

     /users/<userId>/images/<image-file>  
    
  2. how would be good to share a picture on chat-group?

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

this is how our firebase structure deals with group messages

  /groups/<groupId>/<messageId>

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

suggestions would be welcomed

Thanks.


回答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.

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

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.

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.



来源:https://stackoverflow.com/questions/38267536/firebase-storage-structure-example

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