Flutter/Firebase从应用程序读取特定用户的文件
我对Firebase有疑问,我正在制作一个使用Firebase进行firebase用户身份验证的Flutter应用程序。 并且只有该用户才能访问他自己的文档,一旦他登录了应用程序。
已经完成的密码,现在每个用户都将通过控制台上载在存储中的特定文档(.pdf) , 在快速研究中,我注意到我无法为存储中的文件设置唯一的ID(例如,如果上传图像),那么我如何确定只有特定用户才能访问特定文件。我还研究了Firebase安全规则,但是我不确定这是否足以确定或我还需要扑来中的自定义书面代码?
谢谢。
I have question regarding Firebase, I'm making a Flutter App that uses Firebase for user authentication with email & password which is already done, now each user would have specific document (.pdf) uploaded in Storage via console and only that user would have access to his own document that would be shown in the app once he's logged in.
My question is, based on quick research I've noticed that I cannot set a unique ID to a file in storage (if i upload an image for example), so how can I determine that only a specific user can have access to a specific file. I've also taken a look into Firebase Security Rules but I'm not sure if that's enough to determine or do I need custom written code in Flutter as well?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
扩展 @brookyounas的答案:
从Firebase存储中获取PDF位置,然后您应该拥有当前用户的DocumentID的“用户”集合,并将PDF位置(链接)保存在该文档中。
要获取此存储文件链接,请使用:
因此,每次用户登录时,获取当前的用户ID然后使用它。
在线查看PDFS 的软件包
之后,此后使用以下链接: syncfusion_flutter_pdfviewer-用于 href =“ https://stackoverflow.com/questions/62476108/how-to-to-load-and-present-a-pdf-file-from-from-the-web-in-flutter--in-flutter> >
Expanding on @brookyounas's answer:
Get the pdf location from firebase storage then you should have a 'users' collection with documentId of the current user and save the pdf location (link) in that document.
For getting this storage file link, use:
so every time user is logged-in, get the current user-id and then use it.
after this use this link with : syncfusion_flutter_pdfviewer - a package for viewing pdfs online
more on this here: A StackOverflow post about this
从Firebase存储(访问令牌)获取.pdf位置,然后您应该将“用户”收集到当前用户的DocumentID,并在文档中保存.pdf位置。
因此,每次用户登录时,获取当前的用户ID,然后使用它。
get .pdf location from firebase storage(access token) then you should have 'users' collection with documentId of current user and save .pdf location in the document.
so every time user is logged-in, get the current user-id and then use it.