Skip to main content

WebDAV

# echo Hello > /hello.txt
echo Hello | curl -T - 127.0.0.1:8080/hello.txt
# cat /hello.txt
curl 127.0.0.1:8080/hello.txt
# 上传到目录
touch test.txt
curl -T test.txt 127.0.0.1:8080/
# ls /
curl -X PROPFIND http://127.0.0.1:8080/ | xmllint --format -
cors
Access-Control-Allow-Origin: http://example.com
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: ACL, CANCELUPLOAD, CHECKIN, CHECKOUT, COPY, DELETE, GET, HEAD, LOCK, MKCALENDAR, MKCOL, MOVE, OPTIONS, POST, PROPFIND, PROPPATCH, PUT, REPORT, SEARCH, UNCHECKOUT, UNLOCK, UPDATE, VERSION-CONTROL
Access-Control-Allow-Headers: Overwrite, Destination, Content-Type, Depth, User-Agent, Translate, Range, Content-Range, Timeout, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control, Location, Lock-Token, If
Access-Control-Expose-Headers: DAV, content-length, Allow
Access-Control-Max-Age: 3600

Awesome

Server

Server Library

# ghcr.io/hacdias/webdav:latest
# hacdias/webdav:latest
go install github.com/hacdias/webdav/v5@latest
address: 0.0.0.0
port: 6065
behindProxy: true
directory: .
prefix: /webdav
permissions: CRUD
users: []

Client

  • mickael-kerjean/filestash
    • AGPLv3, JS, Go
    • file manager / web client for SFTP, S3, FTP, WebDAV, Git, Minio, LDAP, CalDAV, CardDAV, Mysql, Backblaze
  • macOS Finder
    • WebDAVFS/3.0.0 (03008000) Darwin/24.1.0 (arm64)
    • WebDAVLib/1.3

Client Library

Reading

Props

  • dead properties
    • 额外属性
  • live properties
    • 隐含属性
    • DAV:
propdir?note
resourcetypex<D:collection xmlns:D="DAV:"/>
displaynamex
getcontentlength
getlastmodifiedx
creationdate
getcontentlanguage
getcontenttypemime
getetag一般默认 modtime
lockdiscovery
supportedlockx

MS-Author-Via: DAV

NGINX

location /cache/ {
# The path to the directory where nginx should store the cache contents.
root /path/to/cache/dir;
# Allow PUT
dav_methods PUT;
# Allow nginx to create the /ac and /cas subdirectories.
create_full_put_path on;
# The maximum size of a single file.
client_max_body_size 1G;
allow all;
}

macOS

windows

net use z: https:/my.cloud.domain/remote.php/dav/files/USERNAME/ /persistent:yes /user:USERNAME PASSWORD

@echo off
net use z: /delete
echo mit USERNAME verbinden
timeout /T 3 /nobreak >NUL
net use z: https://your.domain.tld/remote.php/dav/files/USERNAME/ /persistent:yes /user:USERNAME PASSWORD
  • 不使用 HTTPS 连接
    • 可能是 WebDAV Client 不支持 SNI - 使用 IP 访问
    • 可能不支持 TSLv1.1 / TSLv1.2
  • Error 0x800700DF: The file size exceeds the limit allowed and cannot be saved.
    • HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WebClient\Parameters
      • FileSizeLimitInBytes
        • 4GB -> 4294967295