skip to Main Content

I am building a social media application that uses multiple user-uploaded images. I was told that the best tool for handling user-uploading images is Cloudinary, but if possible I want to directly store images in my database. I heard that databases have poor horizontal scaling, which is why solutions like cloudinary are pushed. Is it true that it is a bad idea to have images stored in mongodb? I do not want to use other APIs like cloudinary.

2

Answers


  1. Ussually image URL is stored in database because it always takes less space than whole image data. For example WordPress stores images on server in uploads folder and in database you can only find URL plus title, type, and some additional data, but not whole image file.

    You don’t have to use cloud services to store your images, but it can be faster than loading images from your server. Saving every image in database is definetly not a good idea.

    Login or Signup to reply.
  2. It appears good to store image or any BLOB in database in development, as it would organise very well with other associated data or transaction, However, there are caveats of storing BOLOB (binary, image, …) in database,

    • non-indexable.
    • non-searchable.
    • non-compressible.
    • Manipulations not easy.

    Still, you can store but it will perform poorly at scale and in that case you should avoid storing image in database.

    Storing image in any could provider’s CDN service becomes best choice for performance including other features of image optimisations.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search