How to programmatically mkdir and move uplaoded files? [message #1255952] |
Mon, 24 February 2014 19:59  |
Eclipse User |
|
|
|
I migrated my RAP app from Windows to the Ubuntu 13.10 Server, everything is fine except the file upload/download functionality, I need to programmatically generate directories and put uploaded file into its corresponding directory, as well as to move/rename/read/write the uploaded files.
In Windows it's OK, in Ubuntu Server, it failed, I think that's probably because of Ubuntu's file/directory privilege management at first, so I referred to the privilege of directory /var/lib/tomcat7/webapps, as it's the location to put the uploaded .war files via Tomcat webpage of deployment, I did the following first:
( where MYDIR below is the directory what I hand generate first)
cd /var/lib/tomcat7
sudo mkdir MYDIR
sudo chown R 107:112 MYDIR
sudo chmod R 775 MYDIR
And then, in RAP app, programmatically generate directories and put uploaded file into MYDIR, such as
File myImgDir = new File( "/var/lib/tomcat7/MYDIR/img" );
if (!myImgDir.exists())
myImgDir.mkdir();
but it still fails to generate expected directory /var/lib/tomcat7/MYDIR/img ! I cannot figure it out!!!
Please help me solve this problem, thank you!
|
|
|
Re: How to programmatically mkdir and move uplaoded files? [message #1256381 is a reply to message #1255952] |
Tue, 25 February 2014 06:16  |
Eclipse User |
|
|
|
Well! My approach is correct! After a Tomcat restart, everything was solved as expected! Because the mkdir statement is stated in Activator.java, and which excutes just once and in the very beginning when Tomcat starts!
If you deploy your RAP app on Ubuntu, and provide upload/download functionality, you can refer to my previous post in this thread, the points are to
sudo chown R 107:112 yourUploadDir
sudo chmod R 775 yourUploadDir
Where 107 is Ubuntu user Tomcat's uid!
Hope this information is helpful!
|
|
|
Powered by
FUDForum. Page generated in 0.06322 seconds