VSCode Rest Client的文档缺乏很好的说明。下面是他们给出的一个例子。
POST https://api.example.com/user/upload
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="text"
title
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="image"; filename="1.png"
Content-Type: image/png
< ./1.png
------WebKitFormBoundary7MA4YWxkTrZu0gW--
不知道什么是 <
是为也不 title
?
对于边界部分,我建议阅读 此职位.
<
它是一个表示输入流的符号,你要发送的文件必须和这个文件在同一个目录下。.rest
档,该 restclient扩展 的用途。
快速响应。 boundary是用来定义表单中传递的每一对字段的起点和终点。在你的例子中,有两个表单字段。text="title"
和 image=1.png
字节图像序列。
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="image"; filename="1.png"
Content-Type: image/png
< ./1.png
------WebKitFormBoundary7MA4YWxkTrZu0gW--
其他数据,如 filename="1.png"
或 Content-Type: image/png
表示当您用文件类型输入选择图像时,表单默认加载的附加信息。
字段的另一个例子是 description
.
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="description"
All text of description.
------WebKitFormBoundary7MA4YWxkTrZu0gW