You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

通过WebDAV API在Nextcloud中移动文件失败

问题解决:Nextcloud DAV MOVE请求400错误

问题描述

在Linux命令行通过curl调用Nextcloud的DAV接口操作时:

  • 执行MKCOL创建文件夹成功,命令如下:
    curl 'https://example.com/remote.php/dav/files/user/recording/2023/02/18' --user 'user:password' --request MKCOL
    
  • 执行MOVE移动文件时返回400错误,提示**"服务器无法理解您的浏览器发送的请求"**,原命令:
    curl 'https://example.com/remote.php/dav/files/user/recording/2023-02-18 18-24-52.mp4' --user 'user:password' --request MOVE -H 'Destination:https://example.com/remote.php/dav/files/user/recording/2023/02/18/'
    
  • 开启Nextcloud DEBUG模式后,MKCOL操作有日志记录,但MOVE请求无日志;仅Apache日志留存一条记录:
    [02/Aug/2023:16:54:26 +0800] "MOVE /remote.php/dav/files/user/recording/2023-02-18 18-24-52.mp4" 400 226
    

问题原因

源文件路径中的空格未进行URL编码,DAV服务器无法解析包含空格的请求路径,直接返回400错误。

解决方法

对源路径和Destination头中的空格进行URL编码(将空格替换为%20),修改后的MOVE命令如下:

curl 'https://example.com/remote.php/dav/files/user/recording/2023-02-18%2018-24-52.mp4' --user 'user:password' --request MOVE -H 'Destination:https://example.com/remote.php/dav/files/user/recording/2023/02/18/'

注意保留Destination头路径末尾的/,以此明确目标为文件夹,服务器会自动沿用原文件名完成移动操作。

验证标准

执行修改后的命令后,检查目标文件夹是否存在目标文件;同时查看Apache日志,若返回201或204状态码,则表示移动操作成功。

内容的提问来源于stack exchange,提问作者uncovery

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 15:17:10