Restart a download
Posted 21 December 2010 - 12:06 AM
Sometimes I try to download a large file and it times out. Here is a section of the log:
[20101220 19:11:17] 257 "/ResultDocs" is your current location
[20101220 19:12:20] SIZE 2010-11-30.zip
[20101220 19:12:20] 213 900186896
[20101220 19:12:31] PASV
[20101220 19:12:31] 227 Entering Passive Mode (63,232,53,150,39,85)
[20101220 19:12:31] Opening data connection to 188.8.131.52 Port: 10069
[20101220 19:12:31] RETR 2010-11-30.zip
[20101220 19:12:31] 150-Accepted data connection
[20101220 19:12:31] 150 879088.8 kbytes to download
[20101220 21:37:45] Transfer Timeout (30s). Closing data connection.
[20101220 21:37:45] 888966400 bytes transferred. (99.6 KB/s) (02:25:13)
[20101220 21:38:15] Timeout (30s).
[20101220 21:38:15] 3
[20101220 21:38:15] Client closed the connection.
[20101220 22:42:59] SmartFTP FTP Library 184.108.40.206
My line of code that runs the download is:
ret = objFTP.DownloadFile(FileName, ResultDocPath & FileName, nRestartLo, nRestartHi)
The return value is 3
My question is, how do I try again/resume without restarting from the begining? I know it has something to do with the values nRestartLo and nRestartHi, but I can't find a peice of sample code on your web site that shows that. I'm sure this is a simple procedure. Can you please point me to a sample of this?
Posted 21 December 2010 - 12:32 AM
To get the file size use the Stat() function. In C++:
long nSFTPFlags = 0;
if(nFlags & sfTransferQueueConnectionGetFileItemSize)
nSFTPFlags |= sfFTPLib::ftpSFTPItemAttributeSize;
if(nFlags & sfTransferQueueConnectionGetFileItemModifyTime)
nSFTPFlags |= sfFTPLib::ftpSFTPItemAttributeModifyTime;
if(nFlags & sfTransferQueueConnectionGetFileItemCreateTime)
nSFTPFlags |= sfFTPLib::ftpSFTPItemAttributeCreateTime;
if(nFlags & sfTransferQueueConnectionGetFileItemAccessTime)
nSFTPFlags |= sfFTPLib::ftpSFTPItemAttributeAccessTime;
if (nFlags & sfTransferQueueConnectionGetFileItemPermissions)
nSFTPFlags |= sfFTPLib::ftpSFTPItemAttributePermissions;
// Request other attributes
nSFTPFlags |= sfFTPLib::ftpSFTPItemAttributeBits;
if (nFlags & (sfTransferQueueConnectionGetFileItemOwner | sfTransferQueueConnectionGetFileItemGroup))
nSFTPFlags |= sfFTPLib::ftpSFTPItemAttributeOwnerGroup;
sfFTPLib::enumError ret = m_pSFTPConnection->Stat(bstrPath, nSFTPFlags);
if(ret == sfFTPLib::ftpErrorSuccess)
sfFTPLib::ISFTPItemPtr pLastItem = m_pSFTPConnection->LastItem;
Posted 21 December 2010 - 07:58 PM
I run the DownloadFile option to get a rather large file. It times out before it finishes.
I understand from your post that I need to get the size of the file that is on my local drive and then compare it to the size of the file on the remote site. I am using VB6, so the command to get the size of the file on the remote site is (I think):
s = objFTP.GetFileSize(FileName)
Unfortunately this returns a 15. Not nearly the size. It is actually about 800 meg
I then get the size of the file that was downloaded. In my case it usually dies around 6 or 7 hundred meg.
After I establish the fact that the entire file was not downloaded, I'm not sure what the next line of code would be. I think I run the DownloadFile command again, but this time include the the parameters nRestartLo and nRestartHi. I'm not sure what values to put in each of these parameters.
Is there a snippet of code somewhere on your site that runs through this?
Posted 21 December 2010 - 08:51 PM
Posted 21 December 2010 - 10:47 PM
Now that I can tell that the entire file was not downloaded, how do I resume the download?
Posted 21 December 2010 - 11:41 PM
objFTP.DownloadFile(FileName, ResultDocPath & FileName, nRestartLo, nRestartHi)
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users