cURL / Mailing Lists / curl-library / Single Mail

curl-library

Multipart posting (the hard way)

From: Clarence Gardner <clarence_at_netlojix.com>
Date: Mon, 25 Feb 2002 11:36:21 -0800

Hello, all.

I'm having a problem with a multipart form upload. I'm using the
Python interface (pycurl), and this post works fine:

    setopt(pycurl.URL,
        'https://login.postini.com/exec/Admin?action=change_orgRedir')
    setopt(pycurl.POSTFIELDS, 'targetgroupname=&redir=Batch')
    perform()

Then I need to do a multipart upload. I have the entire multipart
message body in a string, and I've added the multipart header. The
server gets the header, but content-length is always zero, and the
body is not sent.

    opt(pycurl.POST, 1)
    opt(pycurl.POSTFIELDS, f.read())
    opt(pycurl.URL, 'https://login.postini.com/exec/Admin?action=change_batch')
    opt(pycurl.HTTPHEADER, [MPHeader])

I've also tried using READFUNCTION to supply the data with no effect.
In fact, my read function is never called. (I thought maybe pycurl didn't
implement it, but looking at the code, it seems that it does.)

The only documentation I have to go on is the guide, and the setopt
option list from the C interface. They say that one should use formadd
to do this. pycurl doesn't implement that. The guide says
    You can in fact create and post a multipart formpost with
    the regular libcurl POST support described above, but that
    would require that you build a formpost yourself and provide
    to libcurl.
Which is what I'm doing, but it seems like maybe libcurl wants to do
it for me anyway. Any thoughts on this?

Thanks

-- 
Clarence Gardner
Software Engineer
NetLojix Communications
clarence_at_netlojix.com
Received on 2002-02-26