Storing image in MongoDB Database - mongodb

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.

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?

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.

Related

Storing images in MongoDB

I have set up my Mongodb database have connected successfully.
However my project is to create an online cookbook.
My database currently is various recipes but with each document I want an image to be linked to it.
I know I can use gridFS but I would prefer to store the images in the same place as the recipes.
I have seen I can use base64 but that is no appearing for me
I am very new to using Mongo and some advise is greatly appreciated
Store the images in s3 bucket and storing the path of the s3 image in the DB.
Using s3 url you can access the image.

MeteorJS & mongo binary imagefile

Can we use in MeteorJS binary inserted png to the mongodb ? Or do we have to stick base64 ?
I inserted tons of binary png to mongodg for saving the spaces.
I can perfectly utilize it from my C++ codes.
But now need some web frontend.
There are packages like ostrio:files that will do a lot of the work for you. Inserting files into the database works, but puts a load on the database and app to do basic file serving activity, which is better done by something like AWS S3.
Alternatively there is a great service called Filestack https://www.filestack.com/ which is very easy to integrate to, and has a good upload control complete with cropping and resizing. You can just store the image URL's in your database. Quick to implement, and offloads from your server.

using flask+couchdb+couchbase lite

I've been using couchdb + flask for my ionic app.
However, my requirements have changed slightly now and I have to store a lot of lookup files in the app (transferring them everytime is very painful and slow)...
is it possible for me to use couchbase lite alongside flask + couchdb for this?
I have been trying to get some documentation/example apps but there seems to be a dearth of good documentation on this specific issue... but from what i read, it is indeed possible to sync couchbase lite and couchdb.
Another specific question I have is can I use flask to sync the two databases rather than directly connect the couchbase lite and couchdb?
Regards,
Galeej
Use base64 encode if the files are binary or just dump them as a document if they are a text file.
Say I have a file foo.txt with following content:
My name is stupid.
Then I would create a document in Couchbase-lite with key foo.txt and json would look like following:
{
"content": "My name is stupid."
}
Now that string will be replaced with base64 string if file is binary. You will need to decode it before you can use it in application.
Yes, Couchbase Lite (currently) works with CouchDB. Couchbase Lite implements CouchDB's replication protocol.
Regarding Flask, it depends on what you need. To get all the features, I think you'd largely end up having to reproduce the replication protocol, which is tricky.
This link may help: Couchbase-lite and CouchDB

how to upload pictures into mongodb using golang

Any ideas on how to upload picture files into Mongodb using Golang. I have done research and I can find lots of examples with many diiferent languages, but none for Go. Any links for blogs or tutorials would be great help. Thanks.
You may want to read some of the documentation on the mgo driver. Specifically under the gridfs section which covers how to store files in MongoDB. Examples are also available on the mgo website.
Also similar questions have been asked on stack already such as: Store Uploaded File in MongoDB GridFS Using mgo without Saving to Memory

Full-text search on MongoDB GridFS?

Say, if I want to store PDFs or ePub files using MongoDB's GridFS, is it possible to perform full-text searching on the data files?
You can't currently do real full text search within mongo: http://www.mongodb.org/display/DOCS/Full+Text+Search+in+Mongo
Feel free to vote for it here:
https://jira.mongodb.org/browse/SERVER-380
Mongo is more of a general purpose scalable data store, and as of yet it doesn't have any full text search support. Depending on your use case, you could use the standard b-tree indexes with an array of all of the words in the text, but it won't do stemming or fuzzy matches, etc.
However, I would recommend combining mongodb with a lucene-based application (elastic search is popular). You can store all of your data in mongodb (binary data, metadata, etc.), and then index the plain text of your documents in lucene. Or, if your use case is pure full text search, you might consider just using elastic search instead of mongodb.
Update (April 2013):
MongoDB 2.4 now supports a basic full-text index! Some useful resources below.
http://docs.mongodb.org/manual/applications/text-search/
http://docs.mongodb.org/manual/reference/command/text/#dbcmd.text
http://blog.mongohq.com/blog/2013/01/22/first-week-with-mongodb-2-dot-4-development-release/
Not using MongoDB APIs, not that I know of. GridFS seems to be designed to be more like a simplified file system with APIs that provides a straightforward key-value semantic. On their project ideas page they list two things that would help you if existed in production-ready state:
GridFS FUSE that would allow you to mount GridFS as a local file system and then index it like you would index stuff on your disk
Real-Time Full Text search integration with tools like Lucene and Solr. There are some projects on github and bitbucket that you might want to check out.
Also look at ElasticSearch. I have seen some integration with Mongo but I am not sure how much has been done to tap into the GridFS (GridFS attachment support is mentioned but I haven't worked with it to know for sure). Maybe you will be the one to build it and then opensource it? should be a fun adventure