Archived Forum Post

Index of archived forum posts

Question:

Streaming SFTP

Jul 12 '16 at 16:35

Does the SFTP component allow for (or have) file streams.

We have a model where file streams from the browser must be passed to our Gentran based SFTP system and vice-versa.


Answer

Thanks! Chilkat is planning to add streaming functionality to FTP, SFTP, etc., but it's not yet in the current version. (The Chilkat.Stream class was introduced in a recent version, and some proof-of-concept functionality was added to Compression and Crypt2. Other classes will use the Stream object similarly. Unfortunately, it'll take some time..)


Answer

Any suggestions on how to proceed while we're waiting on Chilkat libs?


Answer

Thanks. I should've described a way for an application to implement streaming.

The SSH File Transfer Protocol is defined here: https://tools.ietf.org/html/draft-ietf-secsh-filexfer-02

The reason I point this out is that the operations that are defined (i.e. messages) are very much in the same fashion as the old and very well known "C" file IO functions: open, close fread, fwrite, etc. Therefore, the Chilkat SFTP API has methods that effectively correspond to an underlying operation in the protocol. For example, there is OpenFile (which returns a handle), CloseHandle, and a number of ReadFile and WriteFile methods (each of which takes a handle).

Therefore, if your program wishes to stream to a remote file via SFTP, it can call OpenFile to get the handle, and then call WriteFileBytes or WriteFileText any number of times to continue writing to the open file, until eventually your app would call CloseHandle. The same applies for reading: OpenFile, followed by one or more calls to ReadFileBytes or ReadFileText, and then finally calling CloseHandle.