更新时间:2023-02-21 21:23:37
您正在寻找 --data-binary
参数:
curl -i -X POST host:port/post-file
-H "Content-Type: text/xml"
--data-binary "@path/to/file"
在上面的例子中,-i
打印出所有的标题以便你可以看到发生了什么,并且 -X POST
明确表示这是一个帖子.这两者都可以安全地省略而不会改变线路上的行为.文件路径需要以 @
符号开头,以便 curl
知道从文件中读取.
In the example above, -i
prints out all the headers so that you can see what's going on, and -X POST
makes it explicit that this is a post. Both of these can be safely omitted without changing the behaviour on the wire. The path to the file needs to be preceded by an @
symbol, so curl
knows to read from a file.