Curl用法
跳转到导航
跳转到搜索
- https://curl.se/docs/manual.html
- https://daichangya.github.io/everything-curl/#/book/cmdline-options.zh
操作webdav[编辑 | 编辑源代码]
上传文件到WebDAV服务器:[编辑 | 编辑源代码]
curl -u username:password -T /local/path/to/file.ext "https://webdav.example.com/remote/path/"
下载文件从WebDAV服务器:[编辑 | 编辑源代码]
curl -u username:password -o /local/path/to/save/file.ext "https://webdav.example.com/remote/path/file.ext"
创建WebDAV目录:[编辑 | 编辑源代码]
curl -u username:password -X MKCOL "https://webdav.example.com/remote/new_directory/"
删除WebDAV文件或目录:[编辑 | 编辑源代码]
# 删除文件
curl -u username:password -X DELETE "https://webdav.example.com/remote/path/file.ext"
# 删除目录
curl -u username:password -X DELETE "https://webdav.example.com/remote/path/directory/"
复制或移动文件或目录(需要服务器支持):[编辑 | 编辑源代码]
# 复制文件
curl -u username:password -X COPY -H "Destination: https://webdav.example.com/remote/destination_path/file.ext" "https://webdav.example.com/remote/source_path/file.ext"
# 移动文件
curl -u username:password -X MOVE -H "Destination: https://webdav.example.com/remote/destination_path/file.ext" "https://webdav.example.com/remote/source_path/file.ext"
这些命令中的参数和选项的含义如下:
-u username:password:用你的WebDAV服务器用户名和密码进行身份验证。-T /local/path/to/file.ext:指定要上传的本地文件路径和文件名。-o /local/path/to/save/file.ext:指定下载后的本地文件路径和文件名。-X HTTP_METHOD:指定要执行的HTTP方法,如PROPFIND、MKCOL、DELETE等。-H "Destination: URL":用于复制或移动文件时指定目标URL。URL:WebDAV服务器上的远程路径。