Upload files more then MB's

Aug 23, 2011 at 1:04 PM

Hi,

I am trying to upload file using SFTP. file size is Maximum 1 - 10 MB.

i could not upload the file if more then 32KB.

if file size more the KB then it is going the  loop in else part. 

  if (bytesRead < this.BufferSize)
                {
                    var data = new byte[bytesRead];
                    Array.Copy(buffer, data, bytesRead);
                    this._sftpSession.RequestWrite(handle, offset, data);
                    uploadCompleted = true;
                }
                else
                {
                    this._sftpSession.RequestWrite(handle, offset, buffer);
                }

But keep on waiting for the response. finally i wait till 1 and 1/2 hours also to leave the upload.. there is no reponse from server.

i think no data is writing in to the server. if i tried 12 and 25 KB files it is successfully writing the files.

Where i need to change the code to upload 1 mb file. to get response from server.

i tried changes for on code 

protected const int MAXIMUM_PACKET_SIZE = 150000;

 

protected const int MAXIMUM_PAYLOAD_SIZE = 10241 * 32;

I am not able to success to upload the files. :( 

Could you please let me know what are the changes required in a code to  upload the file size  1- 10 mb files.

Thanks

Rambhopal

Coordinator
Aug 23, 2011 at 2:09 PM

Hi,

First of all try to download latest version of the source code, I made some changes there to address this issue.

 

Also as an alternative, you can set BufferSize property to 16K, this way buffer will never be bigger then 32K.

What it means is instead of chunks of 32K file will be sent in 32K chunks.

FYI, putty clients sends file in 4K chunks.

 

Hope it helps,

Thanks,

Oleg

Aug 24, 2011 at 2:23 AM

HI Oleg,

 

I have downloaded latest code.

i found the buffer size below in a latest downloaded code is this updated one.

this.BufferSize = 1024 * 32 - 38;

could you please help me, do i need to update this code like below?

this.BufferSize = 1024 * 16 - 38;

Thanks

Rambhopal


 

 


Coordinator
Aug 24, 2011 at 2:28 AM

well, you can but you dont have to if you set it to 1024 * 16.

38 needs to be deducted only if you want to use maximum allowable buffer packet size which is 32K then you need to subtract 38 to cover SFTP and SSH packet bytes.

So setting to 1024 * 16 should work.

 

Also, in latest code, I think I checked it in by mistake already, but you can try with any buffer and internally it will break it into smaller chunks that will fit into 32KB buffer.

 

Let me know if you still have a problem.

Thanks,

Oleg

Aug 24, 2011 at 9:18 AM

Thanks :)

 

it works for me. even download also works for me..