Store user images in a web application

I have a web application that is currently being developed in JSP / Servlets.
The application allows users to upload image files for each user account.

What is the best way to store images?
Please consider the following functions that I would like to have before your answer:

  • I am using MySQL now, but it may be possible to switch to another database.

  • I can store images as flat files, but I want the admin account to be able to back up the full database and restart it later. Ideally, backup / reboot should also work with images. (even if the backup was made from another physical machine, and the reboot was performed from another machine)

  • Using BLOB / CLOB is an option that solves problem 2.
    But what if my database becomes very large ?

+6
source share
3 answers

Store them in the file system. It is faster and easier. Often when accessing an image, you still need to save it to a file before you can use it. You can view images using third-party tools. You can save the recordID in the file name to maintain the relationship between the image and the recording.

Many others share this opinion: http://forums.asp.net/p/1512925/3610536.aspx

+1
source

In your case, I highly recommend that you have a blob field in your database and store images in it. Mostly because it is the right place for them. So make a Servlet that retrieves the image of the specified user from the database. For example, /userimage?name=john .

About your size / performance issue:

  • Databases were made (among other things) to store and exchange large amounts of data .
    So this is the best option .

  • Even if you store them on other sites, they will still reduce free space and performance.

  • If you really want to manage LARGE data (> = 3TB, not your case), you can save them in the file system and save the file names in the database. See this question for more information.

+5
source

Just save them to the database ... if your user database "becomes very large", you will have buckets of cash to buy a database server with balls (or even a farm of them) that can handle the load, right now?

-3
source

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


All Articles