curl-and-python

Re: Upload string (and not file) to FTP server...

From: my name <gm41lu53r_at_gmail.com>
Date: Wed, 10 Feb 2010 21:56:16 -0500

I believe you're looking for stringio\cstringio.

http://docs.python.org/library/stringio.html

Google 'pycurl cstringio' and plenty of examples come up.

Alternatively you could just send the data to a script via pycurl that would
reside on a http server. This would use GET, and append the data as
parameters. This is very easy to do with PHP. You would use $_GET['param']
in PHP.

Hope this helps.

On Wed, Feb 10, 2010 at 5:20 PM, Christian Malmquist <cmalmqui_at_imap.cc>wrote:

> Hello,
> Just started scripting a small app that will send some info from a maemo
> phone to my ftp server at regular intervals. Using pycurl for the job, but
> have not yet been able to pass a string across instead of a file.
>
> The below script is how I would like the code to be, and I would be
> grateful if anyone on this list could give me some hints in order to get
> this project flying.
>
> import pycurl
> string_to_upload = "Dette er en test..."
> c = pycurl.Curl()
> c.setopt(c.URL, 'ftp://ftp.server.org/curltest.txt')
> c.setopt(c.FTPAPPEND, 1)
> c.setopt(c.USERPWD, 'curluser:curlpwd')
> c.setopt(c.FTP_USE_EPSV, 1)
> c.setopt(c.WRITEDATA, string_to_upload)
> c.perform()
> c.close()
>
> Thanks in advance for any help!
>
> PS: I guess a better option would be to post the info across to a python
> script running on my webserver. But I opted for the easier FTP approach as
> I am not sure how to write the serverside script. I found plenty of docs
> detailing the libcurl on client side, but not much on how to write the
> server side.
>
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
>

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2010-02-11