0 votes
by (210 points)


I want to know how is guaranteed the integrity of the sftp file transfers.
I mean is there a checksum after transfer?

I try with sftp.Download option ActionOnExistingFiles.ResumeIfPossible, and after transferring x bytes, i change the original file, and transferring continues with no problem and no error is detected.

Thanks, Marcelo.

Applies to: Rebex SFTP

1 Answer

0 votes
by (70.2k points)

The integrity of file transfer is guaranteed by SSH layer in sense: all data sent over the SSH channel is received by the remote end unmodified.

There is no guarantee, that the file is not modified during the transfer in source/target storage.

In case of Upload, the file is exclusively locked for reading by FileShare.Read constraint. In case of Download the behavior is defined by the SFTP server.

The ActionOnExistingFiles.ResumeIfPossible is another case. It is designed to resume interrupted transfers. The documentation says:

Existing files are to be resumed if they are smaller than source

The behavior for ActionOnExistingFiles.ResumeIfPossible is:

  • if a file doesn't exist at target location, the whole file is transferred
  • if the target file is smaller than the source file, the remaining data of the file is transferred, however there is no check for equality of source and target data
  • if the target file is greater or equal than the source file, no data is transferred

If you want to check integrity, you can use the Sftp.GetChecksum() method. But please note, it only works on servers that support the check-file extension.