On Tue, Sep 22, 2009 at 3:50 PM, Phil Bradley <[email protected]> wrote:
> I have set up the Apache FTP server as part of a standalone desktop
> application, that is, the server starts when the application starts.
> This works fine and was very simple to configure and use.
>
> I now want to add an FTPlet that will respond to a file being received.
> My understanding is that I should create a new class which extends
> DefaultFtplet and which overrides onUploadEnd(). I have created such a
> class but I'm not sure how to proceed. My first question is, how do I
> register the FTPlet with the server? I'm not using spring and I'm not
> too familiar with spring conventions so my preference would just be to
> add the FTPlet programmatically. Is this possible?
Sure. The following code should do what you want:
FtpServerFactory serverFactory = new FtpServerFactory();
Map<String, Ftplet> ftplets = new HashMap<String, Ftplet>();
ftplets.put("myftplet", new MyFtplet());
serverFactory.setFtplets(ftplets);
> My second question is, is it possible to get information (the file path
> for example) about the file upload that has just ended?
In 1.0.x, you need to piece this together yourself (get the users
current directory from the session, then get the upload path and merge
them). In 1.1.x we will provide this to the Ftplet.
/niklas