{"id":4322,"library":"webdavclient3","title":"WebDAV Client 3","description":"WebDAV Client 3 is a Python library designed for interacting with WebDAV servers. It provides an easy-to-use interface for common WebDAV operations such as listing, uploading, downloading, copying, moving, and deleting files and directories. This package is a continuation of the original `designerror/webdav-client-python` but leverages the popular `requests` library for HTTP communication instead of `PyCURL`. It is actively maintained, with the current version being `3.14.7`.","status":"active","version":"3.14.7","language":"en","source_language":"en","source_url":"https://github.com/ezhov-evgeny/webdav-client-python-3","tags":["webdav","client","file-management","cloud-storage","http"],"install":[{"cmd":"pip install webdavclient3","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Used for underlying HTTP communication.","package":"requests","optional":false},{"reason":"Used for parsing XML responses from WebDAV servers.","package":"lxml","optional":false},{"reason":"Used for parsing date-related information in WebDAV responses.","package":"python-dateutil","optional":false}],"imports":[{"symbol":"Client","correct":"from webdav3.client import Client"},{"note":"For custom exception handling.","symbol":"WebDavException","correct":"from webdav3.client import WebDavException"}],"quickstart":{"code":"import os\nfrom webdav3.client import Client\n\n# Configure these environment variables or replace with actual values\nWEBDAV_HOSTNAME = os.environ.get('WEBDAV_HOSTNAME', 'https://webdav.example.com')\nWEBDAV_LOGIN = os.environ.get('WEBDAV_LOGIN', 'your_username')\nWEBDAV_PASSWORD = os.environ.get('WEBDAV_PASSWORD', 'your_password')\n\noptions = {\n    'webdav_hostname': WEBDAV_HOSTNAME,\n    'webdav_login': WEBDAV_LOGIN,\n    'webdav_password': WEBDAV_PASSWORD\n}\n\ntry:\n    client = Client(options)\n    \n    # Optional: To skip SSL certificate verification (USE WITH CAUTION IN PROD)\n    # client.verify = False \n\n    # Example 1: List contents of the root directory\n    print(f\"Listing contents of {WEBDAV_HOSTNAME}:\")\n    items = client.list()\n    if items:\n        for item in items:\n            print(f\"- {item.name} (type: {item.type}, size: {item.size})\")\n    else:\n        print(\"No items found or directory is empty.\")\n\n    # Example 2: Create a directory\n    new_dir = 'test_directory_from_python'\n    if not client.check(new_dir):\n        client.mkdir(new_dir)\n        print(f\"Directory '{new_dir}' created.\")\n    else:\n        print(f\"Directory '{new_dir}' already exists.\")\n\n    # Example 3: Upload a file (assuming 'local_file.txt' exists)\n    # with open('local_file.txt', 'rb') as f:\n    #    client.upload_file('remote_file.txt', f)\n    #    print(\"File uploaded.\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")","lang":"python","description":"Initializes a WebDAV client, lists root directory contents, and demonstrates creating a new directory. Credentials should be provided via environment variables for security, or directly in the `options` dictionary."},"warnings":[{"fix":"Upgrade to `webdavclient3==3.14.7` or later. Carefully review and test path constructions, ensuring consistent quoting and proper `webdav_hostname` configuration.","message":"In versions prior to `3.14.7`, inconsistent path quoting for `webdav.root` and URN handling could lead to `RemoteResourceNotFound` errors or incorrect file operations. Ensure your `webdav_hostname` is consistently formatted, especially regarding trailing slashes.","severity":"gotcha","affected_versions":"<3.14.7"},{"fix":"Upgrade to `webdavclient3==3.14.7` or later, which includes a fix for this issue.","message":"Older versions of `webdavclient3` could raise a `KeyError` if the HTTP response from the WebDAV server was missing the `Content-Length` header, which might occur with certain server implementations or empty files.","severity":"gotcha","affected_versions":"<3.14.7"},{"fix":"Verify the exact `webdav_hostname` format required by your specific WebDAV server. Consult the server's documentation for pathing conventions. Experiment with including user-specific paths in the `webdav_hostname` or directly in method calls.","message":"Frequent `RemoteResourceNotFound` errors can occur, particularly with services like Nextcloud or when the `webdav_hostname` is not precisely configured. Sometimes the base URL needs to include specific paths (e.g., `remote.php/dav/files/<username>`), or API calls like `client.list()` might require the username in the path (e.g., `client.list('/username/')`). Disabling checks (`client.webdav.disable_check = True`) might work as a workaround but should be used cautiously.","severity":"gotcha","affected_versions":"All versions"},{"fix":"You may need to manually configure `requests` to use `HTTPDigestAuth` within the client's session, or switch the WebDAV server to use HTTP Basic Authentication if securely appropriate.","message":"If your WebDAV server requires HTTP Digest Authentication, using `webdavclient3` with default options (which rely on `requests`'s basic authentication) may result in `401 Unauthorized` errors. `requests` does not handle Digest Auth automatically without explicit configuration.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Avoid `client.verify = False` in production. Ensure your WebDAV server uses a valid, trusted SSL certificate. If using a custom CA, configure the `requests` session (accessed via `client.session`) to trust your certificate bundle.","message":"Setting `client.verify = False` disables SSL certificate verification. While useful for testing with self-signed certificates, this can expose your application to man-in-the-middle attacks in production environments.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}