When i used CollectionStorer.uploadFile, I got a 409 error like below.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Python WebDAV Library |
Won't Fix
|
Medium
|
Tobias Schlauch |
Bug Description
>>> from webdav import WebdavClient
>>> wc=WebdavClient
>>> f = open("davlib.
>>> 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>
</body></html>
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "./webdav/
self.connection
File "./webdav/
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 |
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 .CollectionStor er("http:// 192.168. 0.34/dav/") py","rb" ) "davlib. py") uploadFile( f)
>>> wc=WebdavClient
>>> f = open("davlib.
>>> resource = wc.addResource(
>>> resource.