cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: CURLFORM_BUFFER vs CURLFORM_PTR

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 31 Aug 2006 00:51:05 +0200 (CEST)

On Wed, 30 Aug 2006, Mohun Biswas wrote:

>> The *BUFFER* ones are for making a CURLFORM_FILE part but instead of
>> getting the file from disk, providing the data in a buffer.
>
> Thanks but that's the source of the confusion because I seem to be making
> file upload parts fine using the *PTR* options.

The NAME and CONTENTS options only set... name and contents. A "file upload
part" is slightly different.

> The doc for CURLFORM_BUFFER says "The given string is used as the value of
> the file name field ..." while CURLFORM_PTRNAME says "... followed by a
> string is used for the name of this part." Thus each of these provides a
> name, and each comes with a way to specify the start of the buffer and its
> length.

CURLFORM_PTRNAME sets the name for the part, CURLFORM_BUFFER sets the *file
name* used in the part and then the BUFFERPTR and BUFFERLENGTH sets the
content of that part and makes it a "file upload part".

> So assuming the contents of a file have been read into a buffer, how is a
> file upload part prepared with *PTR* different from one using *BUFFER*?
> Sorry if I'm being dense.

If you want it to look like a file upload part, you need the BUFFER ones. If
you just want a normal part, you can proceed with NAME and CONTENTS.

I really suggest you use a network analyzer or similar and compare the output
data and I'm quite sure you'll see the differences I (not very successfully)
try to explain.

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2006-08-31