curl-library
CURLOPT_INFILESIZE and padded files
Date: Tue, 16 Jan 2007 10:07:20 -0600
I'm doing a trivial webcam applet. I do not want to store actual files on
my local device (flash memory) and I am using libjpeg. The "obvious" solution
is simple:
FILE *out = fmemopen(...);
off_t size;
/* do jpeg stuff to file */
size = ftell(out);
fseek(out, 0, SEEK_SET);
...
curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) size);
This does not work as expected. Since the file's actual size is "large enough
that I'm sure any JPEG I get will fit in it", curl dutifully uploads the
entire file, then reports error code 18.
An alternative path, which seems to be working but probably shouldn't, is to
simply open ANOTHER file with fmemopen pointing at the same buffer, but
specify the precise size of the jpeg. This works, but curl still reports
error code 18, even though the uploaded file is precisely the same size as
the encoded jpeg data, and appears to be correct.
Is there some obvious and cheap way to tell curl that the file size I am
specifying is not merely a suspicion, but is in fact the amount of data I want
uploaded? Obviously, the overhead of my workaround is trivial compared to
the cost of the network transactions, but it seems like there ought to be
a simpler way.
-s
Received on 2007-01-16