EnterpriseyIntranet / nextcloud-API

NextCloud OCS API for Python
GNU General Public License v3.0
27 stars 27 forks source link

upload_file() returns "Status: Failed" when a file is overwritten #61

Open solarjoe opened 3 years ago

solarjoe commented 3 years ago

When I upload a file that already exists on the server the file is updated but the function upload_file() states

is ok? False
<OCSResponse: Status: Failed>

The logging for urllib3 shows that the call was

urllib3.connectionpool.DEBUG: https://server:443 "PUT /nextcloud/remote.php/dav/files/userc/folder/somefile.txt HTTP/1.1" 204 0

This issue states a similar behaviour and refers to this document:

8.8.5 Status Codes

204 (No Content) - The source resource was successfully copied to a pre-existing destination resource.

WEBDAV seems to have a different interpretation for 204 than default HTTP.

solarjoe commented 3 years ago

I just saw that the section actually refers to COPY, but there are no return codes listed for PUT.

solarjoe commented 3 years ago

For now I just monkeypatched it:

"PUT": [WebDAVStatusCodes.CREATED_CODE, WebDAVStatusCodes.NO_CONTENT_CODE]