Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving images: files or blobs?

Tags:

When you save your images (supose you have lots of them) do you store then as blobs in your Database, or as files? Why?

Duplicate of: Storing Images in DB - Yea or Nay?

like image 305
kurast Avatar asked Aug 28 '09 14:08

kurast


People also ask

Is it better to store images in database or filesystem?

Generally databases are best for data and the file system is best for files. It depends what you're planning to do with the image though. If you're storing images for a web page then it's best to store them as a file on the server. The web server will very quickly find an image file and send it to a visitor.

Can we store image in BLOB?

A Binary Large Object ( BLOB ) is a MySQL data type that can store binary data such as images, multimedia, and PDF files.

What is the difference between file and BLOB?

In summary, the difference between the two storage services is that Azure Blob Storage is a store for objects capable of storing large amounts of unstructured data. On the other hand, Azure File Storage is a distributed, cloud-based file system.

Is it good idea to store images in a database?

Storing images in a database table is not recommended. There are too many disadvantages to this approach. Storing the image data in the table requires the database server to process and traffic huge amounts of data that could be better spent on processing it is best suited to.


2 Answers

I usually go with storing them as files, and store the path in the database. To me, it's a much easier and more natural approach than pushing them into the database as blobs.

One argument for storing them in the database: much easier to do full backups, but that depends on your needs. If you need to be able to easily take full snapshots of your database (including the images), then storing them as blobs in the database is probably the way to go. Otherwise you have to pair your database backup with a file backup, and somehow try to associate the two, so that if you have to do a restore, you know which pair to restore.

like image 149
Brandon Wood Avatar answered Nov 01 '22 19:11

Brandon Wood


It depends on the size of the image.

Microsoft Research has an interesting document on the subject

like image 23
Sean Avatar answered Nov 01 '22 20:11

Sean