This project is read-only.

File Corrupt After SFTP Upload

Nov 28, 2012 at 11:33 PM
Edited Nov 28, 2012 at 11:36 PM

After uploading a file to ftp, the file is 0kb in the ftp folder.

 

 

using (var sftp = new SftpClient(host, user, pass))
             {
                 sftp.Connect();

            
                 using (FileStream file = File.OpenRead(@"S:\Desktop\New folder\TEST.rar"))
                 {                                       
                         sftp.UploadFile(file, @"/my_ftp/TEST.rar", true);                                                                  
                 }                 
                 sftp.Disconnect();
             }

 

Some more detail, I have tried with a .rar and .pdf.  The pdf is only about 113kb and the .rar is about 166kb.  Would preferably like to upload a large zip or rar if I can get this to work.

Thanks in advance for any asistance.

Dec 12, 2012 at 10:19 PM

Hello,

I have the same problem. The file uploads but it seems corrupt after upload.

Did you find a solution to this problem?

Dec 28, 2012 at 1:36 AM

Hi,

 

Please check latest version I committed where I resolved an issues with file could be corrupted on upload due to some blocks are not written.

 

Thanks,

Oleg

 

Dec 28, 2012 at 3:23 PM

Hi Oleg,

Thanks for your reply.

I am infact using the latest version. The SSHNET 4.0. I still face the same issue.

If I set the buffersize of the sftpclient and the buffer size of stream same then it seems to work.

But even that allows me to transfer files up to about 70KB ...

I wanted to send files upto size <= 1MB.

Dec 28, 2012 at 4:10 PM

Hi,

What if you don't change buffer size and use default ones?

I made some changes to default sizes in hope it should work by default.

 

Also,

How do you determine that it is corrupt?

 

Thanks,

Oleg

 

Dec 28, 2012 at 5:24 PM

Hi Oleg,

If I do not change the buffer size, it would only let me upload the files that are < 1024*32-38 (the default buffer size)

I can go to the ftp server and check the file. Sometimes it uploads corrupted as the image seems distorted. Other times the image wont open at all instead a red cross appears. Although, when i check the size on the server it seems to be correct.

Thanks!

 

Dec 28, 2012 at 5:33 PM

Hi,

 

Can you please download latest commit version since I changed default size now to be only 16K and not 32K - 38?

 

Thanks,

Oleg

Dec 28, 2012 at 7:56 PM

Hi Oleg,

I downloaded the latest release. The 12/20/2012 one and used it.

I tried to upload a jpg of size 76587 B but it wont upload properly.

I did not tamper with the buffersize.

Thanks!

Jan 3, 2013 at 10:33 PM

Hmm,

Strange,

Can you send me the code you are using?

Also, would it be possible for me to see the problem for myself?

Also, did you try to upload it to different server?

 

Thanks,

Oleg