firestore database add image to record

拜拜、爱过 提交于 2019-11-29 05:09:14

As a general rule, unless you're storing fairly small icons, I'd say, "Don't do this."

While you can store native binary data in Cloud Firestore (you don't really need to base64-encode your image), you're going to run up against some of the limits in the database -- specifically, a single document can't be more than 1MB large.

Instead, I would store the images themselves in Cloud Storage for Firebase and then just keep the download URLs in Cloud Firestore. Cloud Storage is approximately 7x cheaper in terms of storage costs, has much larger limits in terms of maximum file size, and by grabbing these download URLs, you can take advantage of third-party libraries like Picasso and Glide that can manage the image downloading for you, while also adding nifty features like memory or disk caching or showing placeholder graphics.

You might want to check out this video for more information.

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