In order for it to work properly, I think - you also need to restrict your clients from sending absolute path names in the PUT (STOR) command. If the client sends a command, STOR /dir/file.txt, that would still go to /dir even though the working directory is changed behind the scenes. In other words, the clients should send the STOR command using simple file names (may be relative path names). Your FTPlet could check the parameter to the STOR command and signal an error if it is not appropriate. But, at the same time, some standard FTP clients might not be able to work with your server if you add such restrictions. May be you should consider overriding the default implementation of STOR command instead of using an Ftplet?
Hope it all makes sense. Regards, Sai Pullabhotla On Fri, Jan 29, 2010 at 1:41 AM, Niklas Gustavsson <[email protected]> wrote: > On Thu, Jan 28, 2010 at 7:57 PM, Satish Kaveti <[email protected]> wrote: >> I am using Apache FtpServer 1.0.2. For my application, I need to save >> files with different filename extensions in different directories. I think >> I need to use Ftplet and examine the extensions inside beforeCommand. Is >> it possible to change the save directory inside the Ftplet and continue >> with the default processing for the STOR command ? > > Yes, you should be able to do this in an Ftplet. Override the > beforeCommand to trap STOR (and the other upload methods), then: > session.getFileSystemView().changeWorkingDirectory("the dir for the file > type"); > > /niklas >
