本帖最后由 小猪佩奇 于 2024-11-6 11:30 编辑
webdav协议有很好的通用性,兼容多平台多设备,并且使用简单易上手,想用的舒坦还是要费点心思
服务端不多说,alist对webdav有较好的支持,没有难度
客户端:
- Windows
- Potplayer,kmplayer,RaiDrive,kodi,OneCommander,Mountain Duck,netdrive ❌,rclone,AIMP
- Android
- Nplayer,kmplayer,ES文件管理器,kodi,nova魔改,reex,cx 文件管理器,Solid Explorer,X-plore File Manager,MiXplorer
- IOS
- VidHub,Nplayer,kmplayer,infuse,zFuse, Fileball文件管理器
- 电视TV
- VidHub,Nplayer,kodi,nova魔改
- 若只看阿里可以使用阿里官方合作的
- 欢视商店-阿里云盘TV版,网盘播放器-阿里云盘TV版
- Mac
- VidHub,IINA,Mountain Duck,infuse,netdrive,rclone
- Linux
- davfs2,rclone
- 笔记软件
- Joplin ,思源
复制代码
着重谈在Windows平台的挂载使用
挂载为网络驱动器只是看起来美好
准备(注意备份注册表):
解除50m限制
新建注册表FileSizeLimitInBytes.reg,并将以下内容粘贴保存,覆盖到当前注册表。
win平台最大支持4g
- Windows Registry Editor Version 5.00
- [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WebClient\Parameters]
- "AcceptOfficeAndTahoeServers"=dword:00000001
- "BasicAuthLevel"=dword:00000002
- "ClientDebug"=dword:00000000
- "FileAttributesLimitInBytes"=dword:000f4240
- "FileSizeLimitInBytes"=dword:ffffffff
- "InternetServerTimeoutInSec"=dword:0000001e
- "LocalServerTimeoutInSec"=dword:0000000f
- "SendReceiveTimeoutInSec"=dword:0000003c
- "ServerNotFoundCacheLifeTimeInSec"=dword:0000003c
- "ServiceDebug"=dword:00000000
- "ServiceDll"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,\
- 00,74,00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,\
- 77,00,65,00,62,00,63,00,6c,00,6e,00,74,00,2e,00,64,00,6c,00,6c,00,00,00
- "ServiceDllUnloadOnStop"=dword:00000001
- "SupportLocking"=dword:00000001
复制代码
修改基础验证等级(可选)
如果你的服务端未使用https,需要修改系统默认的验证等级以满足条件。
新建注册表BasicAuthLevel.reg,并将以下内容粘贴保存,覆盖到当前注册表。
- Windows Registry Editor Version 5.00
- [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WebClient\Parameters]
- "AcceptOfficeAndTahoeServers"=dword:00000001
- "BasicAuthLevel"=dword:00000002
- "ClientDebug"=dword:00000000
- "FileAttributesLimitInBytes"=dword:000f4240
- "FileSizeLimitInBytes"=dword:02faf080
- "InternetServerTimeoutInSec"=dword:0000001e
- "LocalServerTimeoutInSec"=dword:0000000f
- "SendReceiveTimeoutInSec"=dword:0000003c
- "ServerNotFoundCacheLifeTimeInSec"=dword:0000003c
- "ServiceDebug"=dword:00000000
- "ServiceDll"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,\
- 00,74,00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,\
- 77,00,65,00,62,00,63,00,6c,00,6e,00,74,00,2e,00,64,00,6c,00,6c,00,00,00
- "ServiceDllUnloadOnStop"=dword:00000001
- "SupportLocking"=dword:00000001
复制代码
编写挂载脚本
虽然Windows支持直接挂载webdav,但由于系统原因,每次登录后都会失效,需要重新挂载,故编写脚本
新建webdav.bat,复制以下内容并保存
- [url=home.php?mod=space&uid=20206]@echo[/url] off
- :: webdav链接以实际为主
- set WEBDAV_URL=https://webdav.com/dav
- :: 用户名
- set USERNAME=用户名
- :: 密码
- set PASSWORD=密码
- :: 挂载盘符到Z
- set DRIVE_LETTER=Z:
- :: 先卸载之前挂载的盘符(如果有)
- net use %DRIVE_LETTER% /delete >nul 2>&1
- :: 映射网络驱动器
- net use %DRIVE_LETTER% %WEBDAV_URL% /user:%USERNAME% %PASSWORD%
- if %errorlevel% neq 0 (
- echo Failed to connect to WebDAV.
- ) else (
- echo Successfully connected to WebDAV.
- )
复制代码
双击即可直接挂载
如不希望出现明文密码,可使用Windows自带的凭据管理,手动添加用户名密码
删除代码中用户名密码,添加以下内容(效果自测)
- for /f "tokens=1-3 delims= " %%a in ('cmdkey /webdav:%TARGET_NAME% ^| findstr /C:"用户名"') do set USERNAME=%%b
- for /f "tokens=1-8 delims= " %%a in ('cmdkey /webdav:%TARGET_NAME% ^| findstr /C:"密码"') do set PASSWORD=%%b
复制代码
编写自启动脚本
新建一个vbs,如webdav.vbs,复制以下内容粘贴保存,注意改为脚本实际路径。
- set ws=WScript.CreateObject("WScript.Shell")
- ws.Run "C:\webdav.bat /start",0
复制代码
将自启动脚本放置于
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp
重启计算机试试,应该可以成功挂载。
Linux应该更简单[debian]
先安装fuse3和rclone
- apt update
- apt install fuse3 -y
- 安装rclone
- rclone config
- 按要求添加webdav信息
复制代码
复制以下内容运行
新建文件夹 /home/webdav /home/temp
- mkdir -p /home/webdav /home/temp && chmod 777 /home/webdav /home/temp
复制代码
复制以下内容运行
不着急,检查命令是否有问题
- rclone mount webdav:/ /home/webdav --cache-dir=/home/temp/ --vfs-cache-mode full --vfs-cache-max-size 1G --vfs-read-ahead 64M --buffer-size 128M
复制代码
没问题再复制以下内容运行
添加守护进程
- cat > /lib/systemd/system/webdav-mount.service <<EOF
- [Unit]
- Description=webdav
- [Service]
- Environment='REMOTE_PATH=webdav:/'
- Environment='LOCAL_PATH=/home/webdav'
- Type=simple
- User=root
- ExecStart=/usr/bin/rclone mount webdav:/ /home/webdav --cache-dir=/home/temp/ --vfs-cache-mode full --vfs-cache-max-size 1G --vfs-read-ahead 64M --buffer-size 128M
- ExecStop=fusermount -qzu /home/webdav
- Restart=on-failure
- [Install]
- WantedBy=multi-user.target
- EOF
复制代码
systemctl start webdav-mount
systemctl status webdav-mount
systemctl enable webdav-mount
df -h
应该就能看到挂载在本地的webdav储存了 |