📜 ⬆️ ⬇️

Where to store images

The other day I thought about the storage of images. There are two alternatives: in the file system and in the database. This is me, by the way, about images for web projects.

I read the literature. As it turned out, but it was not particularly surprising, storing files as files has several advantages:

File storage in the database has one undoubted advantage - encryption. But is it often necessary to take such precautions for images? And it is quite difficult to synchronize the file system with the database: deleted the record, you need to delete the file as well. In the database, the same is solved in one move by cascading deleting the corresponding entry with the BLOB.

In a number of questions, none of the approaches have any clear advantages. For example, backup can be done both for the database and for the file system.
')
The verdict is. It is not that any of the approaches is more correct, because correctness is determined by the task. More simple is the standard way to store images as files. But for some tasks, databases are more suitable.

Source: https://habr.com/ru/post/46466/


All Articles