Async Python 3 client for WebDAV, based on aiowebdav and https://github.com/ezhov-evgeny/webdav-client-python-3
Project description
aiowebdav2
aiowebdav2 is an asyncio based Python 3 client for WebDAV.
It is based on https://github.com/designerror/webdav-client-python and https://github.com/synodriver/aiowebdav.
Installation
$ pip install aiowebdav2
Sample Usage
import asyncio
from aiowebdav2.client import Client
options = {
'webdav_hostname': "https://webdav.server.ru",
'webdav_login': "login",
'webdav_password': "password",
"disable_check": True
}
async def main():
client = Client(options)
client.verify = False # To not check SSL certificates (Default = True)
await client.execute_request("mkdir", 'directory_name')
asyncio.run(main())
Webdav API
Webdav API is a set of webdav actions of work with cloud storage. This set includes the following actions:
check, free, info, list, mkdir, clean, copy, move, download, upload, publish and unpublish.
Configuring the client
Required key is host name or IP address of the WevDAV-server with param name webdav_hostname.
For authentication in WebDAV server use webdav_login, webdav_password.
For an anonymous login do not specify auth properties.
from aiowebdav2.client import Client
options = {
'webdav_hostname': "https://webdav.server.ru",
'webdav_login': "login",
'webdav_password': "password"
}
client = Client(options)
If your server does not support HEAD method or there are other reasons to override default WebDAV methods for actions use a dictionary option webdav_override_methods.
The key should be in the following list: check, free, info, list, mkdir, clean, copy, move, download, upload,
publish and unpublish. The value should a string name of WebDAV method, for example GET.
from aiowebdav2.client import Client
options = {
'webdav_hostname': "https://webdav.server.ru",
'webdav_login': "login",
'webdav_password': "password",
'webdav_override_methods': {
'check': 'GET'
}
}
client = Client(options)
For configuring a requests timeout you can use an option webdav_timeout with int value in seconds, by default the timeout is set to 30 seconds.
from aiowebdav2.client import Client
options = {
'webdav_hostname': "https://webdav.server.ru",
'webdav_login': "login",
'webdav_password': "password",
'webdav_timeout': 30
}
client = Client(options)
When a proxy server you need to specify settings to connect through it.
from aiowebdav2.client import Client
options = {
'webdav_hostname': "https://webdav.server.ru",
'webdav_login': "w_login",
'webdav_password': "w_password",
'webdav_proxy': "http://127.0.0.1:8080",
'webdav_proxy_auth': "xxx",
}
client = Client(options)
If you want to use the certificate path to certificate and private key is defined as follows:
from aiowebdav2.client import Client
options = {
'webdav_hostname': "https://webdav.server.ru",
'webdav_login': "w_login",
'webdav_password': "w_password",
'webdav_ssl': 'sslcontext'
}
client = Client(options)
Or you want to limit the speed or turn on verbose mode:
options = {
...
'recv_speed' : 3000000,
'send_speed' : 3000000,
'verbose' : True
}
client = Client(options)
recv_speed: rate limit data download speed in Bytes per second. Defaults to unlimited speed. send_speed: rate limit data upload speed in Bytes per second. Defaults to unlimited speed. verbose: set verbose mode on/off. By default verbose mode is off.
Also if your server does not support check it is possible to disable it:
options = {
...
'disable_check': True
}
client = Client(options)
By default, checking of remote resources is enabled.
For configuring chunk size of content downloading use chunk_size param, by default it is 65536
options = {
...
'chunk_size': 65536
}
client = Client(options)
Asynchronous methods
# Checking existence of the resource
await client.check("dir1/file1")
await client.check("dir1")
# Get information about the resource
await client.info("dir1/file1")
await client.info("dir1/")
# Check free space
free_size = await client.free()
# Get a list of resources
files1 = await client.list()
files2 = await client.list("dir1")
files3 = await client.list("dir1", get_info=True) # returns a list of dictionaries with files details
# Create directory
await client.mkdir("dir1/dir2")
# Delete resource
await client.clean("dir1/dir2")
# Copy resource
await client.copy(remote_path_from="dir1/file1", remote_path_to="dir2/file1")
await client.copy(remote_path_from="dir2", remote_path_to="dir3")
# Move resource
await client.move(remote_path_from="dir1/file1", remote_path_to="dir2/file1")
await client.move(remote_path_from="dir2", remote_path_to="dir3")
# Download a resource
await client.download(remote_path="dir1/file1", local_path="~/Downloads/file1")
await client.download(remote_path="dir1/dir2/", local_path="~/Downloads/dir2/")
# Upload resource
await client.upload(remote_path="dir1/file1", local_path="~/Documents/file1")
await client.upload(remote_path="dir1/dir2/", local_path="~/Documents/dir2/")
# Publish the resource
link = await client.publish("dir1/file1")
link = await client.publish("dir2")
# Unpublish resource
await client.unpublish("dir1/file1")
await client.unpublish("dir2")
# Exception handling
from aiowebdav.exceptions import WebDavException
try:
...
except WebDavException as exception:
...
# Get the missing files
await client.pull(remote_directory='dir1', local_directory='~/Documents/dir1')
# Send missing files
await client.push(remote_directory='dir1', local_directory='~/Documents/dir1')
# Unload resource
kwargs = {
'remote_path': "dir1/file1",
'local_path': "~/Downloads/file1",
'callback': callback
}
client.upload_async(**kwargs)
kwargs = {
'remote_path': "dir1/dir2/",
'local_path': "~/Downloads/dir2/",
'callback': callback
}
client.upload_async(**kwargs)
Resource API
Resource API using the concept of OOP that enables cloud-level resources.
# Get a resource
res1 = client.resource("dir1/file1")
# Work with the resource
await res1.rename("file2")
await res1.move("dir1/file2")
await res1.copy("dir2/file1")
info = await res1.info()
await res1.read_from(buffer)
await res1.read(local_path="~/Documents/file1")
await res1.write_to(buffer)
await res1.write(local_path="~/Downloads/file1")
Changelog & Releases
This repository keeps a change log using GitHub's releases functionality. The format of the log is based on Keep a Changelog.
Releases are based on Semantic Versioning, and use the format
of MAJOR.MINOR.PATCH. In a nutshell, the version will be incremented
based on the following:
MAJOR: Incompatible or major changes.MINOR: Backwards-compatible new features and enhancements.PATCH: Backwards-compatible bugfixes and package updates.
Contributing
This is an active open-source project. I am always open to people who want to use the code or contribute to it.
Thank you for being involved! :heart_eyes:
Setting up development environment
This Python project is fully managed using the Poetry dependency manager. But also relies on the use of NodeJS for certain checks during development.
You need at least:
- Python 3.11+
- Poetry
- NodeJS 20+ (including NPM)
To install all packages, including all development requirements:
npm install
poetry install
As this repository uses the pre-commit framework, all changes are linted and tested with each commit. You can run all checks and tests manually, using the following command:
poetry run pre-commit run --all-files
To run just the Python tests:
poetry run pytest
Authors & contributors
The content is by Jan-Philipp Benecke.
For a full list of all authors and contributors, check the contributor's page.
License
MIT License
Copyright (c) 2025 Jan-Philipp Benecke
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aiowebdav2-0.6.2.tar.gz.
File metadata
- Download URL: aiowebdav2-0.6.2.tar.gz
- Upload date:
- Size: 140.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ac816ec82d2b5ca012e188e066f8d430be663593e908743e1290a4b41964d93
|
|
| MD5 |
c9f85cbad9956f491f297f8f902b2de6
|
|
| BLAKE2b-256 |
93f10ac8e15e3212529b5354d1a8317522c1a11faa69ea7557a7d6b148f096a2
|
Provenance
The following attestation bundles were made for aiowebdav2-0.6.2.tar.gz:
Publisher:
release.yml on jpbede/aiowebdav2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aiowebdav2-0.6.2.tar.gz -
Subject digest:
4ac816ec82d2b5ca012e188e066f8d430be663593e908743e1290a4b41964d93 - Sigstore transparency entry: 1085602667
- Sigstore integration time:
-
Permalink:
jpbede/aiowebdav2@6f3cfbf5f2bc6f15aaea374f02f6fe6a5bc475f1 -
Branch / Tag:
refs/tags/v0.6.2 - Owner: https://github.com/jpbede
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6f3cfbf5f2bc6f15aaea374f02f6fe6a5bc475f1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file aiowebdav2-0.6.2-py3-none-any.whl.
File metadata
- Download URL: aiowebdav2-0.6.2-py3-none-any.whl
- Upload date:
- Size: 22.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
721f026542e3b064ea1f38cef66c1aa84ac13e70800ddc5b8ca8840d2a993905
|
|
| MD5 |
404d7d9c4e70b119c73a059e48d672f7
|
|
| BLAKE2b-256 |
3764418cca5327a1882d7322174d2aa3a591be2362c7f76ee650b9ad1085ddee
|
Provenance
The following attestation bundles were made for aiowebdav2-0.6.2-py3-none-any.whl:
Publisher:
release.yml on jpbede/aiowebdav2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aiowebdav2-0.6.2-py3-none-any.whl -
Subject digest:
721f026542e3b064ea1f38cef66c1aa84ac13e70800ddc5b8ca8840d2a993905 - Sigstore transparency entry: 1085602700
- Sigstore integration time:
-
Permalink:
jpbede/aiowebdav2@6f3cfbf5f2bc6f15aaea374f02f6fe6a5bc475f1 -
Branch / Tag:
refs/tags/v0.6.2 - Owner: https://github.com/jpbede
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6f3cfbf5f2bc6f15aaea374f02f6fe6a5bc475f1 -
Trigger Event:
release
-
Statement type: