File is used by other person

0 votes
asked Jun 15, 2015 by ndsinfodeveloper (290 points)
retagged Jun 16, 2015 by Tomas Knopp

When i am trying to down laod fiel from Remote Server, but that file is already in uploading process. Is it taken care by Rebex SFTP Obejct and Download it completely? or it will downlaod only partial file?

Is there any way that we can identify that file is in uploading process so we can skip till it is beiung uploaded.?

We face many time where we have downlaoded opartil file instaed of complete file. and i am using sftp.GetFile() method. So i did not know what is the reason behind it .

Applies to: Rebex SFTP

1 Answer

0 votes
answered Jun 15, 2015 by Tomas Knopp (58,890 points)

This is something that you have to manage yourself. From the SFTP protocol perspective there is no difference between a file that is still being uploaded and file that is complete. Once you instruct the Rebex SFTP client to download the file, it simply downloads it as it is (it might be partial and you have no means to determine it from within SFTP protocol).

Do you have the upload process under your control? If yes, it would be the best to upload the file to a special folder under a special name and once the upload finishes then move it to another directory from which you can be sure you can download completely uploaded files.

        Sftp sftp = new Sftp();
        sftp.Login("user", "password");

        // if you have complete control over the uploads, upload the file under a special name
        sftp.PutFile(@"C:\temp\bigFile.txt", "/uploadTemp/bigFile.txt_partial");
        // and only after the file upload is done, then rename the file to its target name
        sftp.Rename("/upload/bigFile.txt_partial", "/uploadDone/bigFile.txt");

Let me know if the above approach works for you.