cURL / Mailing Lists / curl-library / Single Mail


Resuming failed FTP uploads - example code?

From: Philip Bock <>
Date: Tue, 9 May 2006 09:51:04 -0600 (MDT)

I'm trying to use libcurl to upload large files to a somewhat unreliable
FTP server, and so I need to be able to resume the uploads once the
connection fails. I'm having some problems getting this going. Is there
any example code somewhere that might help me understand this? I tried
the search on the mailing list archive page, but didn't find anything
very helpful.

My program calls curl_easy_perform() in a loop, setting CURLOPT_FTPAPPEND
after the first run. My main problem right now is finding out exactly
how much data was successfully transferred. My CURLOPT_READFUNCTION just
pulls data from a FILE*, so I tried just using continuing from the last
time it was called, but of course that doesn't work because the
connection failed somewhere during the last block of the transfer, not
right on the boundary. (By 'block' I mean the data read from one call

I tried using curl_easy_getinfo() to get CURLINFO_SIZE_UPLOAD, but it
seems like that isn't reporting an accurate upload byte count either.
Passing this value to fseek() before calling curl_easy_perform() again
results in broken files being uploaded.

I'm working with MinGW on Windows XP. I'll send my code to the list, if
that will help.

Thanks, Philip Bock
Received on 2006-05-09