cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Issue with partial file transfer

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Fri, 20 Apr 2012 18:46:20 +0200 (CEST)

On Fri, 20 Apr 2012, Marcin Adamski wrote:

> Grzegorz provides libcurl with two parameters: CURLOPT_SEEKFUNCTION,
> CURLOPT_SEEKDATA. This is why he expects libcurl to perform all seeks by
> itself.

Yes clearly, and there might be a seek *forward* using that function in the
case there's a file on the server already.

There won't be any seek backwards to anything since libcurl expects the
application to have that sorted by itself. libcurl avoids all notions of
"files" internally and thinks of streams and it doesn't require the upload to
start at any particular point in this stream. It starts the stream from where
it is.

> How about resuming upload after part of the file is already on the server?

That's the resume feature libcurl offers. It makes libcurl first check the
size of the destination on the server, then seek forward in the stream
accordingly, and then send the rest of the stream to the server.

> Libcurl obtains the remote file size by SIZE command and performs seek on
> CURLOPT_SEEKDATA using CURLOPT_SEEKFUNCTION, because only libcurl knows the
> correct position in file to begin the transfer with.

libcurl seeks relatively. It knows the position is correct to start with (by
definition) and then it seeks forward N bytes.

> So you can't say "What is the correct place is only known by the
> application".

Yes I can. The starting point is defined and set by the application before
libcurl is called.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2012-04-20