V
V
Vladislav Kolotsei2016-03-29 16:19:38
Java
Vladislav Kolotsei, 2016-03-29 16:19:38

How to properly store image files in a web application?

How to properly store images in a web application written in java? At the moment, I have the following principle: a person uploads a photo from the site to the server, the server sends the information to the database and stores the path to the image there. The image itself is placed in the WebContent folder. But after recompiling the project, all photos are deleted. So what's the best way to store files in a web application?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sirs, 2016-03-29
@sirs

Dynamics (pictures, icons, logotypes, etc., everything that can be loaded at runtime) and statics (what never changes at runtime) should be kept separately. Firstly, in order not to lose data when redeploying or adding a new node / instance of your application, and secondly, static content is served much faster through special. server than through a container ala tomcat or some jboss.
Have a look at Apache HTTP Server to get started . Easy to use, minimal settings to get started, lots of examples. Then try a more advanced solution.

T
Timur, 2016-03-31
@timych

See my answer
I can't guarantee that this is a 100% correct solution, but for me it is quite convenient.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question