I need to make a form where users can upload big files (>200Mo). I wanted to launch the uploads in separate threads so users can launch 3-4 uploads and then do something else. My problem is the generated .tmp file is deleted when i run the secondary thread. I use Struts2.
What struts2 gives me:
private String uploadContentType;
private String uploadFileName;
private File upload;
I transfer those information to my thread using its constructor
MyThread thread=new MyThread (sourceName, uploadFileName, upload, user, database);
thread.start();
In the run() method:
System.out.println("Src File name: " + myFile);
System.out.println("Dst File name: " + myFileFileName);
File destFile =new File(UPLOAD_DIRECTORY, myFileFileName);
FileUtils.copyFile(myFile, destFile);
And the error:
Src Filename:
C:\***myeclipsepath***\upload_1949ed75_1002_4ccf_b198_
25faff66563a_00000003.tmp
Dst File name: books.xml
java.io.FileNotFoundException:
C:\***myeclipsepath***\upload_1949ed75_1002_4ccf_b198_
25faff66563a_00000003.tmp (Le fichier spécifié est introuvable)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at org.apache.commons.io.FileUtils.doCopyFile(FileUtils.java:1068)
at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:1021)
at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:968)
at bo.threads.MyThread .run(MyThread .java:68)
When i debug step-by-step i see that the .tmp file disappear when i call thread.start().
So how can i upload files on other threads than the main one ?