gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 11:58:49 26 4
gpt4 key购买 nike

我有一个关于 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com