curl-library
Re: Reading from a stream
Date: Thu, 27 Mar 2008 15:59:11 +0100 (CET)
On Thu, 27 Mar 2008, Robert Bielik wrote:
> A. Letting curl read the contents from the file, which means curl opening
> the file on Win32 by fopen which is not possible since fopen does not
> support UTF-8 filenames (which I need to support swedish char sets).
You can provide your own read callback and do this using whatever calls or
means you deem necessary. Of course if you want a multi-part post you'd then
need to create the entire POST yourself as libcurl doesn't allow just the file
portion of a multipart formpost to get read via the read callback.
But yes, if you use curl_formadd() and add a file name there, libcurl will use
fopen() on that file. Still, you could fix that if that's a bug.
> B. Letting curl post via a buffer, which means I have to read in the whole
> xxx MB size into memory, then use curl to post it. This is of course a big
> no, no (AddFormData as I saw copies the entire buffer (!))
Yes it does and again if you think you can improve this so feel free to do so!
> What I'd want to do is to provide curl with a stream pointer and just tell
> curl how large it is, not having curl test-open the file or anything, then
> just call me back via curl_read_callback and I'll just provide the data
> without curl knowing anything about the underlying file.
That's exactly what libcurl offers, but since you say you want a multi-part
formpost you don't want "without curl knowing anything", you rather seem to
want it to format it accordingly and when offering that formatting it no
longer offers that same read callback approach.
> Please point me in the right direction as I somehow feel that CURL being the
> mature and great lib it is, this must be possible somehow. Right?
It is mature and all, but in spite of this people seem to constantly come up
with new use cases and find new quirks and angles in which libcurl can be
improved...
-- Commercial curl and libcurl Technical Support: http://haxx.se/curl.htmlReceived on 2008-03-27