What's the best way to store uploaded files in web java application? I'm currently storing all uploaded files inside project folder. Unfortunately deploying new version of application is a pain in the arse. Do you have any good practice of storing uploaded files?
Asked
Active
Viewed 2,424 times
0
-
store them in a different place then <. – RamonBoza Nov 05 '13 at 12:22
-
Yeah obvious idea is obvious. I'm just asking about good practice. – J33nn Nov 05 '13 at 12:25
-
2possible duplicate of [recommended way to save files uploaded to a Tomcat servlet](http://stackoverflow.com/questions/18664579/recommended-way-to-save-files-uploaded-to-a-tomcat-servlet) – BalusC Nov 05 '13 at 18:00
-
2By the way, how so "pain in the arse"? You're the one making a major conceptual mistake, not Java/JSF. – BalusC Nov 05 '13 at 18:01
1 Answers
2
You can upload into Database with Blob Type or your can save the file upload into file system but a external folder example c:/Users/youruser/documents/resources to redeploy do not replace.
FileOutputStream fos = new FileOutputStream(System.getProperty("home.dir")+"/resources/file.jpg"); //to save into my documents folder
with jackrabbit(JCR) the sintaxis is similar to
Node.setProperty(java.lang.String name,Binary value)
to store content, i think that the JCR is the best Way

jrey
- 2,163
- 1
- 32
- 48
-
1
-
also you can create system variable in your servlet context example my_resources_path=c:/.... and in your code read the property System.getProperty("my_resources_path") – jrey Nov 05 '13 at 12:27
-