Storing image in MongoDB Database
Solution 1
I would suggest encoding your images to Base64 format. Then you can store them technically as plain text. There is a base64Encode function in dart:convert package.
You can also check this discussion: how to convert an image to base64 image in flutter?
Solution 2
MongoDB has GridFS
for storing files:
A convention for storing large files in a MongoDB database. All of the official MongoDB drivers support this convention, as does the mongofiles program.
It looks like mongo-dart supports it as well although it's missing the documentation.
yash_412
Updated on December 21, 2022Comments
-
yash_412 over 1 year
How can I store images in a MongoDB through Flutter/Dart?
We are developing an android application using MongoDB and Flutter. We want to store images during the registration of users in our app. I already referred the mongo-dart documentation but still, I can't find any solution about this.
-
Alexpandiyan Chokkan almost 4 yearsIMO, Convert & store as
base64
would be better option. -
yash_412 over 3 yearsYa It works. Thanks for your comment
-
-
Femn Dharamshi over 1 yearIs there any blog, or documentation now available for gridfs in mongo-dart?