https://github.com/beshrkayali/webdavclient
WebDAV Client for Nim
https://github.com/beshrkayali/webdavclient
nim nim-lang webdav
Last synced: 6 days ago
JSON representation
WebDAV Client for Nim
- Host: GitHub
- URL: https://github.com/beshrkayali/webdavclient
- Owner: beshrkayali
- Created: 2020-01-02T19:37:15.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-10-19T13:45:38.000Z (over 4 years ago)
- Last Synced: 2024-08-04T03:07:58.866Z (9 months ago)
- Topics: nim, nim-lang, webdav
- Language: Nim
- Size: 20.5 KB
- Stars: 10
- Watchers: 3
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-nim - webdavclient - WebDAV client for Nim. (Web / Protocols)
README
### WebDAV Client for Nim
[](https://github.com/beshrkayali/webdavclient/actions?query=workflow%3ACI)
This is an implementation for some of the basic
operations to communicate with a WebDAV server using Nim.Example usage:
```nim
import webdavclient, asyncdispatch, tables, options# Only Basic auth is currently supported. Make sure you're
# connecting over ssllet wd = newAsyncWebDAV(
address="https://dav.example.com",
username="username",
password="password"
)# Get props (propname request)
let possible_props = waitFor wd.props(
"/",
depth=ZERO
)for url, props in possible_props["/"]:
echo(url, props)# List files
# Default webdav properties don't require a namespace
let t = waitFor wd.ls(
"/",
props=some(@[
"getcontentlength",
"getlastmodified",
"creationdate",
"getcontenttype",
"nc:has-preview",
"oc:favorite",
]),
namespaces=some(@[
("oc", "http://owncloud.org/ns"),
("nc", "http://nextcloud.org/ns")
]),
depth=ONE
)for url, prop in t.pairs:
echo(url)
for pname, pval in prop.pairs:
echo(" - " , pname, ": ", pval)
echo("---")# Downlaod a file
waitFor wd.download(path="files/example.md", destination="/home/me/example.md")# Upload a file
waitFor wd.upload(filepath="files/example.md", destination="/home/me/example.md")# Delete a file
waitFor wd.rm("files/example.md")# Create a collection (directory)
waitFor wd.mkdir("files/new/")# Move a file
waitFor wd.mv(path="files/example.md", destination="files/new/example.md", overwrite=true)# Copy a file
waitFor wd.cp(path="files/new/example.md", destination="files/example.md", overwrite=true)
```