Save image in blob or by route? [closed]

0

What would be most appropriate and a good practice to save images in database

By route or within the manager as data

    
asked by goku venz 25.10.2017 в 13:23
source

1 answer

1

What is currently done is to save the path of the uploaded file and upload the file not even to the server but to a more specialized cloud service such as Amazon Web Store or simply AWS advantages of that, your server does not have to serve those static files that you upload so the load is freed besides those CDNs are specialized in serving static files have several replicas to throughout the world so it will usually have lower load times than if you upload it to your own server.

The following fragment was extracted from Phpcentral - Advantages and disadvantages of saving images in the database

The problems of storing in BD are:

  • Access time to the files: access to the filesystem is always faster than to a database (the db requires connection, authentication, authorization, etc.).

  • Increase in size of the database: if we must persist a large amount of files and / or few but large, this will cause our database to increase in size, and consequently its administration will be more complicated (slower backups and restores, blocking times of the larger data base).

  • Deferred access to files: when files persist in a database, to access them, a database client will always be required to read the content and then present it in the form of a file. In the case of filesystem we can directly access the physical files.
  • Greater complexity: the persistence in the database requires a greater technical knowledge and more code / processes / validations than in the case of the filesystem.
  • Increase in infrastructure requirements: it requires more RAM, processor, disk space, etc., requirements specified by the DBMS to be used in the persistence of files (in practice, usually we are already using a DBMS for our system, so the increase in infrastructure is not usually considerable, it would be different if we had to consider implementing database persistence in a system that does not use a database).

In general almost always choose to use the filesystem to store them but there are different scenarios where it is more practical to store in database.

    
answered by 25.10.2017 в 13:50