+1 vote
by (150 points)
retagged by

I'm using Sftp and FileServer components, and I was wondering if there is a way to let the FileServer know about the progress percentage of a file.

thanks in advance.

Applies to: Rebex SFTP, File Server

1 Answer

+1 vote
by (144k points)

This is quite tricky. Despite its name, the SFTP protocol is not actually a simple file transfer protocol with operations such as "upload file" and "download file".

Instead, it's a remote file system protocol featuring a POSIX-like API. This means that to a server, each transfer appears as a sequence of calls to methods that look somewhat like this:

Handle OpenFile(string path, OpenMode openMode, AccessMode accessMode);
int Read(Handle handle, long position, byte[] buffer, int offset, int count);
void Write(Handle handle, long position, byte[] buffer, int offset, int count);
void Close(Handle handle);

The problem with this is the fact that when the client opens a file for reading or writing, the server doesn't get any idea about what it actually intends to do. If the client opened the file for writing, the server doesn't know how many bytes the client is going to transfer. If the client opened the file for reading, the server doesn't know whether the client actually intends to download the whole file, or only a part of it. Additionally, it's perfectly acceptable for client to access random parts of the file, and even to perform both write and read requests.

This said, if both the SFTP client and SFTP server are under your control and based on Rebex components, the most sensible way to achieve this would be to add a custom SFTP extension the client could use to transmit some "transfer info" structure, informing the server app about what it's trying to achieve or what's currently going on. The server app could in turn use this information to do whatever it needs.

Do you think this approach would be usable in your scenario? Rebex SFTP and Rebex File Server currently don't support custom extensions, but we will consider adding that.

by (150 points)
Hi, thanks for the quick response. Definitely this approach would work for me. We currently use rebex components in the Client and Server.

thanks.
by (150 points)
Hi, do you have an approximate date when this functionality could be available?. In case you decide to add it.

thanks.
by (144k points)
We'll look into this and let you know next week. Chances of adding support for custom extensions are quite high, it looks like a very useful feature! Sorry for slightly delayed responses, we are currently busy finishing the 2017 R1 release of the components.
...