6

I am wondering where should i save files uploaded by user in my application. Right now i am saving them right into webapps/images/uploads(webapps folder is mapped as resource folder via mvc-resource) folder and they are instantly available to display after upload. But i am not sure if this is the right thing to do? how will redeployment of application affect the files already stored there? won't it complicate back ups of application? so basically where should i store them on server? and is this affected somehow by using local(windows) or remote(linux) server Thanks

1 Answer 1

5

I will use a separate directory outside the webapp directory of the application server. In case of update of the application, this seems more appropriate. Just be careful how you save the file name in the database (it's better to save the file without any path, in case of changes).

Sign up to request clarification or add additional context in comments.

5 Comments

exactly this is what i am thinking about, but how can i make this directory acessible for public? how to serve content from it?
forgot to add i am using tomcat 6
You can place a directory in webapp. The content will be available as a static resources. You can also write a servlet which will return the file from the upload directory with appropriate content-type.
@Kartoch - I want to ask you one question. You mean in tomcat/webapp ? or webapp in the project folder ?
@Kartoch - how can I map my app on a directory outside webapp ? I`ve done <resources mapping="/uploads/**" location="D:/uploads/" /> but it doesn not work :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.