cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: ptr data

From: Daniel Stenberg <daniel-curl_at_haxx.se>
Date: Mon, 25 Oct 2004 13:03:37 +0200 (CEST)

On Sun, 24 Oct 2004, Sachin Mahajan wrote:

> I am trying to upload a multimedia buffer (not file) from my C application
> to to the http server via Apache Tomcat servlet. I tried the call as below,
> but dont see any data going thro to the servlet.

No data at all?

> Which one should i use the
> CURLFORM_BUFFER or CURLFORM_PTRCONTENTS versions. What is the difference
> between the two.

It depends on what you want the formpart section to look like. If you want it
to look like a file upload, even though you provide the data in a buffer, you
use CURLFORM_BUFFER (and CURLFORM_BUFFERPTR + CURLFORM_BUFFERLENGTH).

If you "just" want to provide data with a name, then you use
CURLFORM_PTRCONTENTS and CURLFORM_CONTENTSLENGTH.

> Is there anything wrong with the way I am calling the following two methods?
>
> curl_formadd(&formpost,
> &lastptr,
> CURLFORM_COPYNAME, "BinData",
> CURLFORM_BUFFER, "Data",
> CURLFORM_BUFFERPTR, pMValue->multiMedia->data,
> CURLFORM_BUFFERLENGTH,(char*) dataLength,
> CURLFORM_END);

This snippet will create a formpost part that looks like a file upload with
the filename 'Data' in the section called 'BinData'.

> curl_formadd(&formpost,
> &lastptr,
> CURLFORM_COPYNAME, "BinData",
> CURLFORM_PTRNAME, "Data",

CURLFORM_COPYNAME and CURLFORM_PTRNAME are mutually exclusive. You set the
name with one of them. The COPY version copies the name, the PTR version only
points to the buffer you set.

-- 
      Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
       Dedicated custom curl help for hire: http://haxx.se/curl.html
Received on 2004-10-25