TGardner
TGardner

Reputation: 27

How can I go about storing images on a database

I'm wondering how could I go about storing images to a database. Is there a way to store the actual image to a sql or nosql database and then just query the image or would I need to only send the path of a image and then store all images in a folder and direct the image tag to that image. Is there any technologies that will allow me to put the actual image in the cloud and make a get call to it?

Upvotes: 0

Views: 716

Answers (1)

APEALED
APEALED

Reputation: 1663

Some general direction: If you are already using a SQL database, don't want to change the database architecture, and everything else about that database is fine - then you may want to use a few option (remember this is if you are not used a NoSQL DB):

  • a table of paths to the location of the image on your server
  • a table of URLs to static URLs of where the images are being stored

If you are using a NoSQL then storing compressed images in your database may be fine. Some thing to keep in mind:

  • when storing images directly in your database, you can start to add a lot of load on your engine
  • images are large (> 1 MB average) and will easily start to occupy space fast

There are many other practices to keep in mind when choosing. I personally would use some cloud service to reference a static URL that links to my images. This creates a bit more portability and reduces the total size of the table greatly. Check out this discussion for some more details.

Upvotes: 2

Related Questions