简体   繁体   English

React Native如何将图片存入SQLite数据库

[英]How to Store Image in SQLite Database in React Native

I have taken an image with Image Picker and want to store it in sqlite database and retrive it.我用 Image Picker 拍摄了一张图片,想将它存储在 sqlite 数据库中并检索它。 Should I store uri which I got in reponse from Image Picker or what should I do,我应该存储我从 Image Picker得到的响应还是我应该做什么,

Thanks!谢谢!

My honest opinion is to use a dedicated storage space for your images, and store the url and the image meta data in your database.我的诚实意见是为您的图像使用专用存储空间,并将 url 和图像元数据存储在您的数据库中。

You can store your image as a base64, however this will take up a lot of space in your database, and the conversion to base64 and back to binary may even make the image size bigger.您可以将图像存储为 base64,但是这会占用数据库中的大量空间,转换为 base64 并返回二进制甚至可能会使图像尺寸更大。

Stick to a storage solution for your image (Both Google and AWS offers them), and save the url in your database.为您的图像坚持存储解决方案(Google 和 AWS 都提供),并将 url 保存在您的数据库中。

Regards问候
Stephan Bakkelund Valois斯蒂芬·巴克伦德·瓦卢瓦

you have to save image in local storage and save uri of that in SQLite .您必须将图像保存在本地存储中,并将其uri保存在SQLite中。 that's way is the better performance.那就是更好的表现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM