Reputation: 105
We are developing web application using mongodb and scala. We want to store Images uploaded by users. We have two options
Storing Image directly in mongodb database using GridFS.
Storing Images in folder on server.And store only path of that image in database.
Which is best approach so that time required to download the image is less?
Upvotes: 8
Views: 2961
Reputation: 3154
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
This is an awesome gem and simple to implement.
Upvotes: 2
Reputation: 106351
Normally, you want to separate static images from your application server for several reasons:
Given all the above, I'd suggest keeping the images separate, and only storing the path (or lookup ID) of the image in your database.
Upvotes: 7