我应该将图像上传到Cloud Firestore或Firebase Storage吗? [英] Should I upload images to Cloud Firestore or Firebase Storage?

查看:43
本文介绍了我应该将图像上传到Cloud Firestore或Firebase Storage吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能是个愚蠢的问题,但需要像我一样为初学者清除.

Might be silly question but need to clear for beginner as like me.

我知道如何在Firestore数据库上上传图像,但我想而不是使用FirebaseStorage为什么我们不使用base64字符串来上传图像,这可能是如此简单?还是字符串长度有一些限制?

I know how to upload image on Firestore database but I thought instead of use FirebaseStorage why we are not using base64 string for upload image, it might be so easy? Or there is some limitation on string length?

〜PS:我没有尝试使用base64字符串在Firestore上上传图像.

~ PS : I haven't tried with base64 string to upload image on Firestore.

推荐答案

Cloud Firestore用法和限制"文档指出,文档的最大尺寸"为1 MiB (1,048,576 bytes).
这是图像的少量数据,仅允许在单个文档中存储低分辨率图像.您可以将图像存储在多个文档中作为一种解决方法,但这不必要地很复杂,并且 Firebase Storage 可以完美地解决此问题.

The Cloud Firestore "Usage and limits" documentation states that the "Maximum size for a document" is 1 MiB (1,048,576 bytes).
This is a small amount of data for images and will only allow to store low resolution images in single documents. You could store images across multiple documents as a workaround, however, that is unnecessarily complicated and Firebase Storage solves this issue perfectly.

此外,在聆听文档中的任何更改时,您还将下载整个图像(整个文档).如果您有一个包含image (base64 string)likes (int count)字段的文档,并且尝试收听likes的实时更新,则每次客户端都将下载完整图像.

Additionally, you will be downloading the whole image (whole document) when listening to any change in a document. If you have a document that has an image (base64 string) and a likes (int count) field and you try to listen for real time updates of the likes, you will be downloading the full image every time client side.

Firebase存储很可能是您要搜索的内容,因为它可以存储任何对象大小(与容量一样大),它会为您提供下载网址的,并且您无需处理任何编码或解码(尽管

Firebase Storage is therefore most likely what you are searching for as you can store objects of any size (as large as your capacity), it provides you with download URL's, and you do not have to handle any encoding or decoding (although Cloud Firestore allows blob's, i.e. byte data, as well).

这篇关于我应该将图像上传到Cloud Firestore或Firebase Storage吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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