Curl用法:修订间差异
跳转到导航
跳转到搜索
无编辑摘要 |
无编辑摘要 |
||
| (未显示同一用户的2个中间版本) | |||
| 第1行: | 第1行: | ||
* https://curl.se/docs/manual.html | * https://curl.se/docs/manual.html | ||
* https://daichangya.github.io/everything-curl/#/book/cmdline-options.zh | * https://daichangya.github.io/everything-curl/#/book/cmdline-options.zh | ||
= 操作webdav = | |||
== 上传文件到WebDAV服务器: == | |||
<syntaxhighlight lang="bash"> | |||
curl -u username:password -T /local/path/to/file.ext "https://webdav.example.com/remote/path/" | |||
</syntaxhighlight> | |||
== 下载文件从WebDAV服务器: == | |||
<syntaxhighlight lang="bash"> | |||
curl -u username:password -o /local/path/to/save/file.ext "https://webdav.example.com/remote/path/file.ext" | |||
</syntaxhighlight> | |||
== 创建WebDAV目录: == | |||
<syntaxhighlight lang="bash"> | |||
curl -u username:password -X MKCOL "https://webdav.example.com/remote/new_directory/" | |||
</syntaxhighlight> | |||
== 删除WebDAV文件或目录: == | |||
<syntaxhighlight lang="bash"> | |||
# 删除文件 | |||
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/" | |||
</syntaxhighlight> | |||
== 复制或移动文件或目录(需要服务器支持): == | |||
<syntaxhighlight lang="bash"> | |||
# 复制文件 | |||
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" | |||
</syntaxhighlight>这些命令中的参数和选项的含义如下: | |||
* <code>-u username:password</code>:用你的WebDAV服务器用户名和密码进行身份验证。 | |||
* <code>-T /local/path/to/file.ext</code>:指定要上传的本地文件路径和文件名。 | |||
* <code>-o /local/path/to/save/file.ext</code>:指定下载后的本地文件路径和文件名。 | |||
* <code>-X HTTP_METHOD</code>:指定要执行的HTTP方法,如PROPFIND、MKCOL、DELETE等。 | |||
* <code>-H "Destination: URL"</code>:用于复制或移动文件时指定目标URL。 | |||
* <code>URL</code>:WebDAV服务器上的远程路径。 | |||
[[分类:命令行工具]] | [[分类:命令行工具]] | ||
[[分类:Curl]] | |||
2023年9月21日 (四) 03:08的最新版本
- 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服务器上的远程路径。