473,320 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

uploading files to a webdav SSL enabled server

rbt
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::DAV and somone reccomended
PHP's curl functions as well, but I wanted to try this in Python first.

Many thanks,
rbt
Jul 19 '05 #1
2 4940
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
Jul 19 '05 #2
rbt <rb*@athop1.ath.vt.edu> wrote in message news:<d7**********@solaris.cc.vt.edu>...
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::DAV 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
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Independentsoft | last post by:
Hello, Independentsoft is pleased to announce the Release Candidate 2 of WebDAV .NET v1.0, the leading WebDAV protocol API component for Microsoft .NET Framework and Microsoft .NET Compact...
0
by: Michael G. Schneider | last post by:
I just started playing around with WebDAV. The basic configuration is done and works. For example I am able to open a document via HTTP from within Word and save it. What I am really looking for...
0
by: drasticp | last post by:
I want to create a custom webdav server by implementing IHttpHandler in my own class and firing it via IIS 6.0 Wildcard Application Maps. I have written my HttpHandler class implementing...
6
by: subscriptions | last post by:
Hi, So here's the deal; I'm hosting several people on a virtual server running Linux (White Box Enterprise), each of which has an internet presence. (Apache webserver.) They're also web...
2
by: D. Shane Fowlkes | last post by:
I'm about to build in some functionality where my client's staff can do some kind of basic upload to a folder or series of folders on our web server and allow authenticated users to know the UID...
4
by: Shannon Hardin | last post by:
I'm trying to build a routine that will take a specified file from the user's local hard drive, and copy it to a remote server via WebDAV. I've tried using both HttpWebRequest and FileWebRequest,...
0
by: lknight643 | last post by:
I have an asp.net application that works with a SQL server database on server No. 1 but I want to upload files for storage to Server No. 2 that is accessible only from the Internet. If the file...
4
by: DudDav | last post by:
Hi All, I have been trying to configured WebDAV on our current IIS server as an alternative to FTP and have had some mixed success but I've hit a brick wall with one problem. The server...
0
by: teddy06 | last post by:
I have written code for read mails from exchange server. I have used webdav in my code. Its was working fine once upon a time. Currently configuration settings of client has been changed . so i...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.