0

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?

jrey
  • 2,163
  • 1
  • 32
  • 48
J33nn
  • 3,034
  • 5
  • 30
  • 46
  • 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
  • 2
    possible 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
  • 2
    By 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 Answers1

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

http://jackrabbit.apache.org/jcr-api.html

jrey
  • 2,163
  • 1
  • 32
  • 48