Hi,
I'm trying ver.0.1.2. I set up webdav server by apache ver.2.2.13 on fc11.
When i used CollectionStorer.uploadFile, I got a 409 error like below.
>>> from webdav import WebdavClient
>>> wc=WebdavClient.CollectionStorer("http://192.168.0.34/dav/")
>>> f = open("davlib.py","rb")
>>> wc.uploadFile(f)
2010-02-22 13:40:57,175: DEBUG: Wrote 12018 bytes.
2010-02-22 13:40:57,184: INFO: Transfered 12018 bytes.
2010-02-22 13:40:57,184: DEBUG: Status 409: Conflict
2010-02-22 13:40:57,184: DEBUG: RESPONSE Body: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>409 Conflict</title>
</head><body>
<h1>Conflict</h1>
<p>Cannot PUT to a collection.</p>
<hr />
<address>Apache/2.2.13 (Fedora) Server at 192.168.0.34 Port 80</address>
</body></html>
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "./webdav/WebdavClient.py", line 332, in uploadFile
self.connection.putFile(self.path, newFile, header=header)
File "./webdav/Connection.py", line 178, in putFile
raise WebdavError(reason, status)
WebdavError: Conflict
This is because http server receive collection path only, and not received the resource name.
I think, uploadFile method seemed to need file name to upload as its args instead of file object like below.
def uploadFile(self, newFile, lockToken=None):
"""
Write binary data to permanent storage.
@param newFile: File containing binary data.
@param lockToken: None or lock token from last lock request
@type lockToken: L{LockToken}
"""
#assert isinstance(newFile, types.FileType), "Argument is no file: " + file.__class__.__name__
assert lockToken == None or isinstance(lockToken, LockToken), \
"Invalid lockToken argument %s" % type(lockToken)
header = {}
if lockToken:
header = lockToken.toHeader()
try:
f = open(newFile,"rb")
self.connection.putFile('/'.join([self.path,newFile]), f, header=header)
finally:
if not f.closed:
f.close()
As far as i tried, I could upload a file correctly.