+1 vote
by (130 points)
edited

Is there a version of the library that has a common interface for Ftp and for Sftp. I need to toggle between the two in a library however because I don't see a common interface, I essentially have to duplicate all the code, with exactly the same calls.

Applies to: Rebex FTP/SSL, Rebex SFTP

3 Answers

+1 vote
by (70.2k points)
edited

We are planning to release a Remote File System which is exactly what you want. It wasn’t officially released yet, but you can download a preview from http://www.rebex.net/extras/RFS.ConsoleSample.zip

by (130 points)
Thanks, I will take a look.
by (130 points)
We browsed through the new common RemoteFileSystem which is shared with Ftp and SFtp, however we noticed that the calls differ from what is currently on both of those. At the moment to get around the problem, since both use the same method calls, we're using C#'s dynamic variables and in the new RemoteFileSystem, we'd have to change all of our method calls. Since all the calls are shared, could the API remain the same?
by (144k points)
Which calls do you mean? Could you post their names? Some methods are missing from RemoteFileSystem and some are different, but some of this can't be changed - for example, Rebex FTP's GetList returns an instance of FtpList while SFTP's GetList returns SftpItemCollection - these classes are very similar but not identical. Therefore the common API's GetList must return something else (although it will probably be a common ancestor of both FtpList and SftpItemCollection. The same applies to some other methods, properties and events.
by (144k points)
To sum it up: please do let us know what exactly which calls were missing, different or otherwise problematic. The common API is a work in progress and we might be able to do something about this issue. Thanks!
0 votes
by (140 points)
edited

I notice that the original question was answered over a year ago. Do you now have the Remote File System completed, or if not will you soon? We need to switch back and forth between ftp and sftp as well.

by (70.2k points)
edited

The common interface for FTP and SFTP is already implemented. It will be available within the next public release. You will be able to use new IFtp interface for common functions as follows:

// declare common interface
IFtp client;

// the protocol to use
if (UseFtp)
{
    Ftp ftp = new Ftp();
    ftp.Connect(...);
    ftp.Login(...);
    client = ftp;
}
else
{
    Sftp sftp = new Sftp();
    sftp.Connect(...);
    sftp.Login(...);
    client = sftp;
}

// do some work
client.ChangeDirectory(...);
client.GetFile(...);

If you want to get the trial beta version, please let us know.

by (140 points)
edited

When you get a directory listing will there be a common object for both ftp and sftp for the list collection and its items?

by (70.2k points)
edited

Yes, there will be the DirectoryItemCollection class which is ancestor of FtpCollection and SftpCollection. It will contain the DirectoryItem objects (ancestor of FtpItem and SftpItem). The code can look like this:

IFtp client = ...;
DirectoryItemCollection list = client.GetList();
foreach (DirectoryItem item in list)
{
    Console.WriteLine("{0} {1} ...", item.Name, item.Length, item...);
}

Please note, the DirectoryItemCollection and the DirectoryItem are not final names. They will be probably renamed.

by (140 points)
edited

Sounds good, we're looking to implement something ASAP, so when is your public release of this scheduled?

by (70.2k points)
edited

The next public release is scheduled for November 2011. I can send you beta version if you want to try the common API.

by (330 points)
edited

I've got the current trial version from the website, but I'd love to get the beta with the common interface, since this is exactly what I need to do as well.

0 votes
by (200 points)
edited

Ok, ignore this, I was using the old binaries.

Good work! Thanks a lot.

by (18.0k points)
edited

The IFtp interface was released in version release 2012R1. You can also find it in our on-line help.

The interface is a part of Rebex.Networking.dll so it is available in most of Rebex components, especially in Rebex FTP/SSL, Rebex SFTP, Rebex File Transfer Pack or Rebex Total Pack.

by (18.0k points)
edited

For now, we've not promoted the interface too much. You can look on a small example of initializing IFtp instaces.

We are planning to complete the common FTP / SFTP usage with providing a new FileTransfeClient class. It will implement the IFtp interface and it will also maintain a uniform creating of FTP or SFTP connections. Together with this new class we will publish appropriate set of samples and tutorials.

...