I have been using %Net.FtpSession and while it works, its handling of file/directory listings from an FTP server is less than ideal and, while this is due to the FTP protocol itself, the class could be written to handle this as would an FTP client such as FileZilla and command line/class FTP handlers for other languages. I was wondering if anyone knows how the Ensemble adaptor works with this in case it provides code that would help, though the source does not seem to be available. Below are the issues I see in FTP, some are based on past experience writing our own FTP handler in the past, and how that affects the class.
There are 2 methods available:
This issues an NLST command to the FTP server to get a list of filenames back. The description says "will return an array of filenames including their path".
There are several issues with this. Firstly, the returned list may or may not include the directory even though the class says it will and there is no code to check or enforce it in the class. Secondly, some FTP servers will include directory names and others will not and there is no indicator to say if an entry is a directory or not. Lastly, there are no file details returned with the list so to get size or datetime you issue additional FTP commands that can be performed by additional class methods, however, not all FTP servers support these commands.
So, inconsistencies and limited information make this a poor choice but possible lack of support for additional commands make it worse.
The good news is all FTP servers support the LIST command used and it returns file details along with the file list, the bad news is it returns a human readable string for each entry and different FTP servers format this in different ways. This means that the code needs to have knowledge of the different formats and be able to decode them to turn the string information into something usable.
For an example, FileZilla,a very popular FTP client, uses LIST and decodes it, as can be seen if you turn on raw directory listings in the debug options.
I have wriitten code that deals with this by decoding LIST responses but this means I have to maintain it while I had expected that an FTP class might be aware of, and deal with, these issues and I assume the Ensemble adaptor must do this.