I am currently facing a challenge assigned by my superior.
The task at hand involves the storage of a substantial volume of images, each approximately 10 MB in size, and the subsequent delivery of these images to clients upon request via web browsers. The preferred technological stack for this endeavor is Java in combination with MongoDB.
Upon initial review, it seems that I have two primary options to consider:
Option #1:
Storing the images directly in MongoDB using gridFS.
Option #2:
Storing the images on a filesystem and utilizing the database to store indices and other related metadata.
I would greatly appreciate any insights or suggestions on this matter. If feasible, please also provide links to any similar projects for reference.
Thank you in advance for your assistance.
Haven’t tried anything yet. Just trying to figure out what is the best solution here.
2
Answers
If there is a guarantee that the size will not override the document maximum it’s always possible to store the actual picture as a binary.
See this thread for further reading regarding both gridFS and storing as binary:
https://www.mongodb.com/community/forums/t/process-of-storing-images-in-mongodb/15093
It’s most feasible to store image hashes or names in the database that will identify the actual files. So if you need to refresh an image you can do that via file changes rather than database updates.
You can also store the images in the database directly, but then you will not be able to separate the database from the images. If you only have the references in the database, then you can store the images at one storage place and the database at another.