简体   繁体   English

使用 flutter 将图像作为 blob 存储在 mysql 数据库中

[英]Storing image's as blob in mysql database with flutter

Is it good to store blob images in mysql database and fetch them in the flutter app using php or should I store them in a separate folder with their links in database?将 blob 图像存储在 mysql 数据库中并使用 php 将它们存储在 flutter 应用程序中是否很好,或者我应该将它们存储在单独的文件夹中,并将它们的链接存储在数据库中? For a database with above 100K images what would be a better solution.对于具有超过 100K 图像的数据库,什么是更好的解决方案。 Storing image paths would be difficult while backup i think.我认为在备份时存储图像路径会很困难。 Can someone suggest what to do.有人可以建议做什么。 It will be very helpful.这将非常有帮助。 Thank you in advance!先感谢您!

The best practice is to store the images in a folder and just save their path's in the database.最佳做法是将图像存储在一个文件夹中,并将其路径保存在数据库中。 So basically convert the images to base64 and send it to your webserver in a regular POST method.所以基本上将图像转换为 base64 并以常规 POST 方法将其发送到您的网络服务器。 then in your PHP code decode the base64 to a file and save the image wherever you want, just remember to keep track of the image new path so can fetch it later.然后在您的 PHP 代码中将 base64 解码为一个文件并将图像保存在您想要的任何位置,只需记住跟踪图像的新路径,以便以后获取它。 fetching, by the way, works the same.顺便说一句,获取的工作原理是一样的。 good luck:)祝你好运:)

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

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