We are developing a web application using mongodb and scala. We want to save images uploaded by users. We have two options.
Saving an image directly to the mongodb database using GridFS.
Saving images in a folder on the server. And save only the path to this image in the database.
What is the best approach, so the time it takes to download the image is less?
Usually you want to separate static images from your application server for several reasons:
Given all of the above, I suggest saving individual images and saving only the path (or search identifier) ββof the image in your database.
Choose the second option
2.Storing Images in folder on server.And store only path of that image in database.
For this purpose you can use gem mongoid-paperclip
mongoid-paperclip
It is a stunning stone and easy to implement.