FTP, Proxy and urllib2

Discussion in 'Python' started by Martin Brodbeck, Jun 7, 2004.

  1. Hello,

    I want to upload a file with ftp over a proxy. I know that I have to use
    urllib2 to be able to connect over a proxy.
    But I don't have any idea how I can upload the file :)
    I'm a python-novice and hope that you can give me some tips or code
    samples...

    Thanks for your help
    Martin
     
    Martin Brodbeck, Jun 7, 2004
    #1
    1. Advertising

  2. Martin Brodbeck

    John J. Lee Guest

    Martin Brodbeck <> writes:

    > I want to upload a file with ftp over a proxy. I know that I have to
    > use urllib2 to be able to connect over a proxy.
    > But I don't have any idea how I can upload the file :)
    > I'm a python-novice and hope that you can give me some tips or code
    > samples...

    [...]

    I think you need to use ftplib. urllib2 is for fetching files, not
    uploading them (unless there's some obscure feature of ftp URLs that
    allows it).

    Use ftplib.


    John
     
    John J. Lee, Jun 7, 2004
    #2
    1. Advertising

  3. John J. Lee wrote:

    Hi John,

    > I think you need to use ftplib. urllib2 is for fetching files, not
    > uploading them (unless there's some obscure feature of ftp URLs that
    > allows it).
    >
    > Use ftplib.


    Ok, but what if there is a proxy between the client and the ftp server?
    Can ftplib handle this? How?

    Thanks
    Martin
     
    Martin Brodbeck, Jun 8, 2004
    #3
  4. Martin Brodbeck

    fishboy Guest

    On Tue, 08 Jun 2004 09:05:38 +0200, Martin Brodbeck <>
    wrote:

    >John J. Lee wrote:
    >
    >Hi John,
    >
    >> I think you need to use ftplib. urllib2 is for fetching files, not
    >> uploading them (unless there's some obscure feature of ftp URLs that
    >> allows it).
    >>
    >> Use ftplib.

    >
    >Ok, but what if there is a proxy between the client and the ftp server?
    >Can ftplib handle this? How?
    >
    >Thanks
    >Martin


    ftplib wont work with a proxy.

    I'm assuming you mean a HTTP proxy for FTP like Squid. In which case,
    you might get it work using an HTTP PUT command through urllib2.py.

    PUT isn't part of urllib :|

    But searching for 'urllib python http put'I found this
    http://infomesh.net/2001/QuickPut/QuickPut.txt
    Which uses urllib/urllib2. And urllib will work through a proxy.

    So it's not inconceivable that you could get something to work.

    Personally, I'd just ssh tunnel to a machine outside and forward a
    port from there. But I have an ssh fixation.

    ><{{{*>
     
    fishboy, Jun 8, 2004
    #4
  5. fishboy wrote:

    Hello,

    > ftplib wont work with a proxy.
    >
    > I'm assuming you mean a HTTP proxy for FTP like Squid. In which case,
    > you might get it work using an HTTP PUT command through urllib2.py.
    >
    > PUT isn't part of urllib :|
    >
    > But searching for 'urllib python http put'I found this
    > http://infomesh.net/2001/QuickPut/QuickPut.txt
    > Which uses urllib/urllib2. And urllib will work through a proxy.
    >
    > So it's not inconceivable that you could get something to work.
    > [...]


    Interesting. But I can't get it to work. Isn't there a small example
    somewhere? QuickPut seems not to be the right one...

    Thanks
    Martin
     
    Martin Brodbeck, Jun 8, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. O. Koch

    FTP with urllib2 behind a proxy

    O. Koch, Aug 7, 2003, in forum: Python
    Replies:
    4
    Views:
    1,327
    John J. Lee
    Aug 14, 2003
  2. Bob McCormick

    Re: FTP with urllib2 behind a proxy

    Bob McCormick, Feb 25, 2004, in forum: Python
    Replies:
    1
    Views:
    418
    Josiah Carlson
    Feb 25, 2004
  3. Bob McCormick

    Re: FTP with urllib2 behind a proxy

    Bob McCormick, Feb 25, 2004, in forum: Python
    Replies:
    0
    Views:
    395
    Bob McCormick
    Feb 25, 2004
  4. jakecjacobson

    FTP example going through a FTP Proxy

    jakecjacobson, Jan 7, 2009, in forum: Python
    Replies:
    3
    Views:
    2,123
    jakecjacobson
    Jan 8, 2009
  5. D. Buck
    Replies:
    2
    Views:
    560
    D. Buck
    Jun 29, 2004
Loading...

Share This Page