Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > uploading files to a webdav SSL enabled server

Reply
Thread Tools

uploading files to a webdav SSL enabled server

 
 
rbt
Guest
Posts: n/a
 
      05-25-2005
Has anyone used pure python to upload files to a webdav server over SSL?
I have no control over the server. I can access it with all of the
various webdav GUIs such as Konqueror, Cadaver, etc. by using a URL like
this:

webdavs://dav.hostname.com/user_name/uploads

My goal is to upload files automatically with a python script. The
server requires authentication over SSL which I can do with urllib2 like
this:

def auth_against_url(url, username, password):

# This is a slightly modified version that I found here:
# http://simon.incutio.com/archive/2004/07/15/instant

import urllib2
import base64
request = urllib2.Request(url)
b64 = base64.encodestring('%s:%s' % (username, password))[:-1]
request.add_header('Authorization', 'Basic %s' % b64)
try:
f = urllib2.urlopen(request)
print f.read()
f.close()
return True
except urllib2.HTTPError, e:
print e
return False

auth_against_url('https://dav.hostname.com/user_name/uploads',\
str.strip(raw_input('Enter User ID: ')),\
str.strip(raw_input('Enter Password: ')))

If urllib2 supported webdav, I think I'd be in business, but it doesn't.
Any one who can provide pointers on this? I've googled around to no
avail. I've began playing with Perl's HTTP:AV and somone reccomended
PHP's curl functions as well, but I wanted to try this in Python first.

Many thanks,
rbt
 
Reply With Quote
 
 
 
 
Peter Hansen
Guest
Posts: n/a
 
      05-25-2005
rbt wrote:
> Has anyone used pure python to upload files to a webdav server over SSL?


We were not using SSL at the time (since it wasn't supported in standard
Python, as I recall), but we successfully used the webdav client that
was part of Zope a few years ago. I suspect you could adapt it to use
the new SSL support relatively easily. Check back for version 2.4 or so
if you can't find it in the latest Zopes. (I haven't looked at Zope for
a few years now, so I don't know whether it's still included.)

-Peter
 
Reply With Quote
 
 
 
 
Paul Boddie
Guest
Posts: n/a
 
      05-26-2005
rbt <(E-Mail Removed)> wrote in message news:<d720om$3cr$(E-Mail Removed)>...
> Has anyone used pure python to upload files to a webdav server over SSL?
> I have no control over the server. I can access it with all of the
> various webdav GUIs such as Konqueror, Cadaver, etc. by using a URL like
> this:
>
> webdavs://dav.hostname.com/user_name/uploads


I suppose it would be nice if urllib(2) supported WebDAV in this way,
but you should still be able to use httplib to interact with the
server. Uploading in WebDAV is just a matter of doing an HTTP PUT if I
recall correctly, and I don't think that any of the special status
codes or responses are involved; in this sense WebDAV overlaps with
traditional HTTP.

[...]

> If urllib2 supported webdav, I think I'd be in business, but it doesn't.
> Any one who can provide pointers on this? I've googled around to no
> avail. I've began playing with Perl's HTTP:AV and somone reccomended
> PHP's curl functions as well, but I wanted to try this in Python first.


Searching for "DAV Python" revealed the following projects:

http://www.lyra.org/greg/python/
http://cvs.infrae.com/packages/pydavclient/dav/

Really it's just a matter of talking HTTP to a server and parsing the
special messages that are returned for certain request methods, but
you may not even need to do that if you're just uploading files.

Paul
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
WebDAV: Connect Ruby to a WebDAV Server Michael Dichtl Ruby 7 07-09-2007 04:42 PM
webdav client with SSL Brad Tilley Ruby 0 10-24-2006 07:22 PM
ftp uploading vs. control panel uploading Dung Ping HTML 10 01-16-2006 10:43 AM
Python SSL Socket Client to Java SSL Server. HELP me PLEASE. Krzysztof Pa¼ Python 1 09-26-2003 08:36 PM
trace enabled, get app. error, doesn't enabled, on runs without error Gabor ASP .Net 3 08-26-2003 09:54 AM



Advertisments