How to resume upload on a large file using SFTP?

This forum is not monitored by the SmartFTP staff. If you have a license please contact technical support by email.
Post Reply
ds1
Posts: 15
Joined: Fri Feb 04, 2011 4:59 am

How to resume upload on a large file using SFTP?

Post by ds1 » Tue Feb 08, 2011 9:28 pm

We are using SmartFTP Library Version 2.0.107.0. We are trying to resume upload of file of size 8GB using SFTP over SSH connection. The code we are using is as follows:

_objSFTP.UploadFile(fileName, fileName, LocalfileLowValue, 0, ServerfileLowValue, 0) = sfFTPLib.enumError.ftpErrorSuccess

The problem is when the start byte of the file is a large value. The function "UploadFile" accepts only integer values for low and high and if the size of the start byte is in GB then we cant use an integer. Can anyone tell me how I can resume uploading of a large file over an SFTP connection?

mb
Posts: 12029
Joined: Thu Oct 11, 2001 1:24 pm
Display name: Mat (SmartFTP)
Contact:

Re: How to resume upload on a large file using SFTP?

Post by mb » Tue Feb 08, 2011 9:33 pm

Split up your 64-bit integer into a lower and higher 32-bit part. Then pass it to the function.

Dim value As System.UInt64
value = 342342323423432;
Dim hi As System.UInt32
hi = System.Convert.ToUInt32(value >> 32)
Dim lo As System.UInt32
lo = System.Convert.ToUInt32(value)

UploadFile(file1, file2, lo, hi, lo, hi)

file1 != file2
Last edited by mb on Tue Feb 08, 2011 9:53 pm, edited 1 time in total.

ds1
Posts: 15
Joined: Fri Feb 04, 2011 4:59 am

Re: How to resume upload on a large file using SFTP?

Post by ds1 » Thu Feb 10, 2011 9:54 pm

I have tried the solution you gave for the problem but still I am still getting the same error. The exact size of file which I want to upload is 9127565312 bytes and I am resuming upload from 2548465664 bytes so the code is:

Dim value As System.UInt64
value = 2548465664;
Dim hi As System.UInt32
hi = System.Convert.ToUInt32(value >> 32)
Dim lo As System.UInt32
lo = System.Convert.ToUInt32(value)

However when we are calling the function as:

UploadFile(file1, file2, lo, hi, lo, hi)

The line gives the error "Arithmetic operation resulted in an overflow"

mb
Posts: 12029
Joined: Thu Oct 11, 2001 1:24 pm
Display name: Mat (SmartFTP)
Contact:

Re: How to resume upload on a large file using SFTP?

Post by mb » Thu Feb 10, 2011 10:54 pm

Please install the latest build: https://www.smartftp.com/ftplib/download

Then use the new UploadFileEx() function:

Dim startPosition As System.UInt64
startPosition = 2548465664;
UploadFileEx(file1, file2, startPosition)

Post Reply