When i used CollectionStorer.uploadFile, I got a 409 error like below.

Bug #598069 reported by Tobias Schlauch
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Python WebDAV Library
Won't Fix
Medium
Tobias Schlauch

Bug Description

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

Changed in python-webdav-lib:
importance: Undecided → Medium
status: New → In Progress
assignee: nobody → Tobias Schlauch (tobias-schlauch)
milestone: none → 0.2.0
Revision history for this message
Tobias Schlauch (tobias-schlauch) wrote :

Unluckily the design is not self-explanatory. The uploadFile method is only usable when
you are referring to a new non-existing resource or an existing resource. I.e. it always refers to the actual used URI.
When using a URI pointing to a collection the server correctly responds with 409 Conflict as collection contain no binary content.
Effectively the uploadFile method is intended to be inly used with ResourceStorer instances.

Your example should work as follows:

>>> from webdav import WebdavClient
>>> wc=WebdavClient.CollectionStorer("http://192.168.0.34/dav/")
>>> f = open("davlib.py","rb")
>>> resource = wc.addResource("davlib.py")
>>> resource.uploadFile(f)

Changed in python-webdav-lib:
status: In Progress → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.