FTP, Proxy and urllib2

  • Thread starter Martin Brodbeck
  • Start date
M

Martin Brodbeck

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
 
J

John J. Lee

Martin Brodbeck said:
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
 
M

Martin Brodbeck

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
 
F

fishboy

John J. Lee wrote:

Hi John,


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.
 
M

Martin Brodbeck

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top