cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Resuming failed FTP uploads - example code?

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Tue, 9 May 2006 09:59:39 -0700

On Tue, May 09, 2006 at 09:51:04AM -0600, Philip Bock wrote:
> 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.
[...]
> 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.

It sounds like you're doing the right thing except that curl can't
know exactly how much data made it to the server before the connection was
broken. Instead, on your next connection to the server request the length of
the file that made it to the server, i.e. the equivalent of a
'curl -I ftp://host/file'. I'm not sure the best way to do this--probably a
NOBODY request and look for a 'Content-Length:' header. That's the value
you'll need to pass into fseek().

>>> Dan

-- 
http://www.MoveAnnouncer.com              The web change of address service
          Let webmasters know that your web site has moved
Received on 2006-05-09