What is the most robust way to get an absolute path to the file, so
that I can do new File(path) to access that file? Below seems a bit
flakey, but I can't think of anything better.
String file = request.getFileSystemView().getCurrentDirectory().getFullName();
User user = request.getUser();
String name = user.getName();
String home = user.getHomeDirectory();
if ( home.startsWith(".") ) {
home = home.substring( 1 );
}
File file = new File( System.getProperty("user.dir") + home + file +
request.getArgument() );
Mark
Knutsen Rolf Aslak wrote:
In the onUploadEnd you get the FTPRequest Object.
The getArgument will give you the current uploaded filename.
The request.getFileSystemView().getCurrentDirectory().getFullName() will
give you the directory the user is in.
In onUploadEnd:
System.out.println("Argument: " + request.getArgument());
System.out.println("CurrDir: " +
request.getFileSystemView().getCurrentDirectory().getFullName());
FTP Client:
------------------------
Connected to local.
220 Service ready for new user.
User (local:(none)): admin
331 User name okay, need password for admin.
Password:
230 User logged in, proceed.
ftp> cd test
250 Directory changed to /test
ftp> put pom.xml
200 Command PORT okay.
150 STOR
226 Data transfer okay.
FTP Server:
-----------------------
------- Apache FTP Server started ------
Open connection - 127.0.0.1
Login success - admin
Argument: pom.xml
CurrDir: /test
Close connection : 127.0.0.1 - admin
Combinding those should give you access.. ???
-Aslak Knutsen
-----Original Message-----
From: Mark Proctor [mailto:[EMAIL PROTECTED]
Sent: 31. oktober 2006 15:32
To: [email protected]
Subject: Re: ftp server and upload events
Can anyone provide an insight into this?
We want to automate the handling of incoming files. We have something
hacked now, which is a hard coded singleton in the ftp server code that
broascasts events, but looking for the correct way to do this.
Mark
Mark Proctor wrote:
Is there an existing way to hook into an upload event so I can
reforward a file as an event? I've looked at the ftplet and while it
emits events when the upload is finished, it does not expose the
actually file it uploaded only a stream. I'm guessing if I re-opened
the stream it would either fail or re-stream it from the client, both
undesired effects.
If this is currently not possible I'm thinking of either adding a new
param to the event that passes the File, or introduce a whole new
event.
Mark
--
This email has been verified as Virus free
Virus Protection and more available at http://www.plus.net