post - cURL POST --data-binary vs --form

标签 post curl

我有一个关于 cURL 使用的简单问题。在我的 Google 搜索或手册页中没有找到太多内容来获得明确的答案。

here谈论使用 --data对比 --form关于发送文件/附件。我很想知道主要区别是什么以及在什么情况下您会选择 --data-binary VS --form ?

POST“正文”可以通过 --data (for application/x-www-form-urlencoded) 发送或 --form (for multipart/form-data) :

-F "foo=bar"                  # 'foo' value is 'bar'
-F "foo=<foovalue.txt"        # the specified file is sent as plain text input
-F "foo=@foovalue.txt"        # the specified file is sent as an attachment

-d "foo=bar"
-d "foo=<foovalue.txt"
-d "foo=@foovalue.txt"
-d "@entirebody.txt"          # the specified file is used as the POST body

--data-binary "@binarybody.jpg"

最佳答案

HTML 4.01 Specification section on Forms 中解释了差异。 :

application/x-www-form-urlencoded is the default content type.

The content type "application/x-www-form-urlencoded" is inefficient for sending large quantities of binary data or text containing non-ASCII characters. The content type "multipart/form-data" should be used for submitting forms that contain files, non-ASCII data, and binary data.

关于post - cURL POST --data-binary vs --form,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14063311/

相关文章:

python - 有序请求参数python

curl - Elasticsearch 2.1 : how to delete by query using curl

swift - 从模块 CCurl 调用 curlHelperSetOptString 时出错 - swift -Kitura

c - 如何使用 C 中的 Curl 通过 FTP 恢复文件下载?

jquery post codeigniter 验证

java - 如何将 Exchange.getRequestURI().getQuery() 的结果存储在变量中并使用它来获取授权码

xml - curl 剥离 xml 文件中的 CRLF

php - curl 获取远程文件并同时强制下载

java - 将新行放入 mysql 表时放入 Response.created 的 URI

java - NoSuchMethodError : org. apache.commons.codec.binary.Base64.(I)V 在 org.apache.http.impl.auth.BasicScheme.(BasicScheme.java:65)