cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Newbie pycurl question

From: Kjetil Jacobsen <kjetilja_at_cs.uit.no>
Date: 18 Jun 2002 16:17:40 +0200

On Mon, 2002-06-17 at 16:45, John Blakeley wrote:
> Hi there
>
> On Fri, 14 Jun 2002, John Blakeley wrote:
>
> > On Thu, 13 Jun 2002, Daniel Stenberg wrote:
> > > I'm not sure if "mr pycurl" (Kjetil Jacobsen) is reading this list, so I CC
> > > this reply over to him.
> > >
> > > I believe there are some examples in the pycurl tarball on how to perform a
> > > few different simple operations. Aren't those good enough?
> >
> > There are no PUT examples, only GET and POST.
> >
>
> Correct me if I am wrong: I had a quick look through the src, and it looks
> like PUT and UPLOAD have not been implemented in pycurl yet.

hello, it appears you're wrong ;)

pycurl supports both put and upload. there are no examples, though.

something like this should work for put (untested):

----------------------------------

import os, pycurl

url = 'http://url.to.put/'
filename = '/filename/to/put'
filesize = os.path.getsize(file)

f = open(filename)
c = pycurl.init()
c.setopt(pycurl.URL, url)
c.setopt(pycurl.PUT, 1)
c.setopt(pycurl.INFILE, f)
c.setopt(pycurl.INFILESIZE, filesize)
c.perform()
c.cleanup()

----------------------------------

hope this helps,

        - kjetil

>
> Salut/.
>
> J/.
>
>
>
> This e-mail (and any attachments) is confidential and may contain personal
> views which are not the views of the BBC unless specifically stated.
> If you have received it in error, please delete it from your system, do not use,
> copy or disclose the information in any way nor act in reliance on it and notify
> the sender immediately.
> Please note that the BBC monitors e-mails sent
> or received. Further communication will signify your consent to this.

----------------------------------------------------------------------------
                   Bringing you mounds of caffeinated joy
>>> http://thinkgeek.com/sf <<<
Received on 2002-06-18