0 votes
by (390 points)
edited

Is there a method to directly transfer files between 2 ftp servers without having to download locally and then push to the second site?

Applies to: Rebex FTP/SSL, Rebex SFTP

2 Answers

+1 vote
by (18.1k points)
edited
 
Best answer

1) For the FTP protocol, it is possible to use the CopyToAnotherServer method on some FTP servers. It utilizes the FXP functionality, which should be supported by the source FTP server software.

// connect to the source server
Ftp session1 = new Ftp();
session1.Connect(server1);
session1.Login(username1, password1);

// connect to the destination server
Ftp session2 = new Ftp();
session2.Connect(server2);
session2.Login(username2, password2);

// copy a single file from server1 to server2
session1.CopyToAnotherServer(session2, sourcePath, destinationPath);

Please note that even if the FTP server supports the server-to-server transfers (FXP), it is usually disabled by default.

2) For the SFTP protocol, there is unfortunately nothing like the FXP technology.

by (390 points)
edited

Thanks Jan. Am I reading that correctly that it will only copy one individual file?

by (18.1k points)
edited

Yes. Unfortunately, multiple-file operations (using wildcards or filesets) are not supported by the CopyToAnotherServer method.

by (390 points)
edited

Ok, I can work with that if it's possible to zip the files in the directory before transfer and unzip on arrival at destination. Using the rebex package is it possible to do that? If so do you have a link to a sample

by (390 points)
edited

Or maybe the correct question is, is this the right way to go to conduct transfers between 2 ftp servers. Should I be using a memorystream to conduct the transfers between 2 servers? I am using ftp/ftps protocols

by (18.1k points)
edited

Zipping of several files is not possible when using server-to-server transfer. The transfer is controlled by pure FTP commands and there is no FTP command for zipping files on the remote server.

Server-to-server transfer is advantageous when your FTP client has a slow connection to FTP server(s), while the connection between servers is fast.

If your client computer has a quite fast connection to both FTP servers and you need to transfer multiple files, I'd recommend to download the files to a temporary folder on your client computer and then upload them to the target FTP server. You can use the Upload method with the TransferMethod.Move argument to atomically delete files from the temporary folder just after uploading.

A memorystream cannot be used in multiple-file Rebex operations since we don't provide any mechanism to wrap several files into a single stream.

by (390 points)
edited

Thanks, That was what my research was showing too. I was hoping to bypass local storage even if it was temporary but it's nothing that I can't work with. I just need to keep on top of the network team to ensure they don't continue to allow the drives to get full so I can't do the transfers. Maybe I should even add that as a pretest before the transfer attempt. Thanks again Jan very helpful.

0 votes
by (230 points)
edited

What is the methods to perform sftp-syncrhonous file transfer()

by (58.9k points)
edited

See list of file transfer synchronous methods available in Rebex SFTP:

for multi file operations there are these synchronous methods:

...