curl-library
how to pass curl_formadd() metadata around?
Date: Mon, 21 Aug 2006 22:35:34 -0400
I'm looking for advice on the best way to handle something. Briefly, I
need to upload a set of files with a multipart form on a frequent basis.
It's working now using CURLFORM_FILE but what I'd prefer to do is mmap()
each file and pass it in as a buffer and a size using, say,
CURLFORM_PTRCONTENTS and CURLFORM_CONTENTSLENGTH. Why this way? Two reasons:
1. It appears that CURLFORM_FILE sets up a callback which reads the file
a block at a time; I think mmap-ing it and treating it as a contiguous
buffer might be faster, at least for large files.
2. More important, it's possible for another process to append to a file
at the same time I'm uploading it. In order to avoid corruption I want
to be able to pass in the file size as of when it was opened. This
seems safe against appending whereas CURLFORM_FILE might pick up some
portion of the new data and CURLFORM_COPYCONTENTS might choke on a big file.
The problem is that every file mmap-ed must be munmap-ed when the
transfer is done, and munmap takes both the address and the size as
parameters. So these things need to be saved somehow.
Is there a way to dig out the values passed with CURLFORM_PTRCONTENTS
and CURLFORM_CONTENTSLENGTH from the easy handle, once per each part?
I've also thought of sprintf-ing these pairs into strings, making a list
of them with curl_slist_append(), then storing the slist in the handle
using CURLOPT_PRIVATE. Unfortunatelythere's no documented way of
traversing an slist.
Any ideas?
Thanks,
M Biswas
Received on 2006-08-22