gpt4 book ai didi

httpie - 带有 HTTPie 的 multipart/form-data 中一个文件的 Content-Type

转载 作者:行者123 更新时间:2023-12-04 00:11:41 26 4
gpt4 key购买 nike

我用 HTTPie发布一个
multipart/form-data 请求(传递 -f 选项)。它包括一个
文件字段(使用 @ 选项)。对应的部分
多部分请求有一个伪头 Content-Disposition ,但确实
没有伪头 Content-Type .

怎么可能添加这样的Content-Type对于特定文件?

为了完整起见,这是我现在发送的内容(如 -p B 所示):

--xyz
Content-Disposition: form-data; name="file"; filename="file.txt"

Hello, world!
This is the content of the file.

--xyz

但这是我需要发送的:
--xyz
Content-Disposition: form-data; name="file"; filename="file.txt"
Content-Type: text/plain

Hello, world!
This is the content of the file.

--xyz

或者换句话说,就像 CURL 等效选项: -F "file=file.txt;type=text/plain" .

最佳答案

这对我有用:

http -f POST :8080/submit-file metadata=@metadata.json files@file1.jpeg files@file1.jpeg

该文档对我有帮助: https://httpie.org/doc#file-upload-forms
=@使 httpie 发送内容类型为 text/plain .

关于httpie - 带有 HTTPie 的 multipart/form-data 中一个文件的 Content-Type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33943850/

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