Resuming upload

0 votes
asked Apr 16, 2015 by maynero (390 points)

In this page it says that resuming is possible. How in Rebex Sftp will I know that it will actually resume the correct file? Let say for example the same file already exist in the remote server with different size but there are actually different file, will it resume it or overwrite?

1 Answer

0 votes
answered Apr 17, 2015 by Tomas Knopp (58,580 points)

Hello,

no, actually the Sftp client does not check whether the partially transferred file is the "right" one when using the basic resume with the PutFile method.*

For an automatic auto resume please check our MultiFile operation sftp.Upload which you can instruct to auto-resume via the ActionOnExistingFiles.ResumeIfPossible.

So checking whether the partial file content that you want to resume really corresponds to the local file is up to you. The FTP protocol and Rebex FTP supports computing remote hashsums, which comes in handy in this situation, but the Sftp protocol hashsums are unsupported by many SFTP servers, so we do not support it in Rebex SFTP.

*Example:
So if you have a failed transfer, let's say that 1024B were transferred out of 3KB file ( = OrigFile), and then you start with the resume, count the remote length, but just before you connect to the server and finish the resume, then somebody else changes the remote file and it is now 1050B long with different content ( = DifferentFile).

In fact if you now continue with the original resume from offset 1024, then the bytes from remote offset 1024 will get overwritten and the rest will be appended. So you will enad up having bytes 0-1023 from file 'DifferentFile' and the rest (bytes 1024-3071) from the 'OrigFile'.

commented Apr 17, 2015 by maynero (390 points)
I would like to use the sftp.Upload but i cant seem to find a way to upload the file with different name. sftp.PutFile accepts remote path containing a new filename. I don't want to rename the local file, i just want it to be upload with a new filename. is that possible in sftp.Upload?
commented Apr 20, 2015 by Tomas Knopp (58,580 points)
Hello,

no this is not possible, sorry. The Upload/Download methods are designed as multi-file operations. So although they also allow you to transfer only one file at a time, they will not allow to specify complete remote file name (s), simply by its API design.

In this case, where you want to upload directly a file with a different name, please use the single file operation PutFile and GetFile, and then use the standard resume as described at http://www.rebex.net/sftp.net/features/single-file-operations.aspx#resume.
...