Archived Forum Post

Index of archived forum posts

Question:

Resuming FTP Upload

Oct 23 '12 at 05:14

Hi, actually i am programming a FTP upload routine for large files. Because the files might have up to 1GByte, the user should be able to interrupt transfer and to resume (continue) the transfer later.

My question: I coded it like described below, but when i reenter the code when resuming the transfer, the AsyncPutFileStart does nothing and terminates after a few seconds- so the transfer does not continue. What is wrong in my code- how do i have to code such a behaviour?

Thanks a lot!

My code:

ftp.put_RestartNext(true);
//Async upload
bSuccess = ftp.AsyncPutFileStart(locFile,remFile);
if (bSuccess)
{      
while (!ftp.get_AsyncFinished() && !(ptrThreadControl->ptrAbortTransfer)) { ptrThreadControl->ptrCurrentTransfered = ftp.get_AsyncBytesSent(); *ptrThreadControl->ptrCurRate = ftp.get_UploadRate(); Sleep(1000); }

if (ftp.get_AsyncSuccess()) { *ptrThreadControl->ptrCurrentTransfered = ftp.get_AsyncBytesSent(); } else {....}


Answer

It may help if you post the value of asyncLog - the async version of lastErrorText according to this example: http://www.example-code.com/vcpp/ftp_asyncUpload.asp


Answer

I tried to get the LOG but there was no last error! So what i found was that the Abort Flag was still set. -sorry for that stupid bug!

But meanwhile i implemented also the ftp.AsyncAbort in case my interruption flag is set. It does interrupt but now i have a strange behavour when i restart and complete the transfer: I want to transfer a 25MB file. When i interrupt at 10MB and restart transfer again it transfers me 15MB and signals "AsyncFinished" with success. But the file on the server is just 15MB and not 25MB.

Any Idea?

My code now: while (!ftp.get_AsyncFinished()) { ptrThreadControl->ptrCurrentTransfered = ftp.get_AsyncBytesSent(); ptrThreadControl->ptrCurRate = ftp.get_UploadRate();

        Sleep(1000);

        //User requests Abort
        if (*ptrThreadControl->ptrAbortTransfer)
        {
          ftp.AsyncAbort();
          //break;
        }
      }