0 votes
by (8.4k points)

Is possible to uppload multiple parts of a single file by Rebex FTP component?

Applies to: Rebex FTP/SSL

1 Answer

0 votes
by (8.4k points)
Best answer

Yes, but the FTP server must support the COMB command. The COMB is a proprietary command and is not defined nor endorsed by any FTP-related RFC. It is supported by e.g. GlobalScape or Titan FTP serves.

The COMB command combines source files into a single target files. It uses the following syntax:

COMB <target-file> <source-file-1> ... <source-file-n>

Source files are deleted after the correct run. If the target exists has already existed then the source files are appended to the end in the given order.

Here is an example of uploading of two parts of a single file to the FTP server and subsequent combining them together by the Rebex FTP component:

const string host = "...";
const int port = 21;
const string user = "...";
const string passwd = "...";
const string dir = "C:/";
const string file = "file.zip";

string src = Path.Combine(dir, file);
long offset;
long length;

// connect
Ftp ftp = new Ftp();
ftp.Connect(host, port);
ftp.Login(user, passwd);

// put
offset = 0;
length = 10000; // first 10 Kbytes
ftp.PutFile(src, "file1", offset, 0, length);
offset = length;
length = long.MaxValue; // rest of the file
ftp.PutFile(src, "file2", offset, 0, length);

// combine
ftp.SendCommand(string.Format("COMB {0} file1 file2", file));
FtpResponse response = ftp.ReadResponse();
if (response.Group != 2)
    throw new FtpException(response);