Since file-upload is a feature that will benefit many applications, this proposes an extension to HTML to allow information providers to express file upload requests uniformly, and a MIME compatible representation for file upload responses.
- 1867 文档中说明文件上传是一种常见的需要求,但是使用 html 中的 form 表单格式却不支持,
- 提出了一种兼容此需求的 mime type。
- 解决接口测试流程中文件上传的问题
- 指定 name
- 指定 filename
- 指定 content-type
r = requests.post("https://httpbin.ceshiren.com/post",
files={"hogwarts_file": open("hogwarts.txt", "rb")})
# key值需要替换为文件名
# value 对应为文件二进制流
import requests
r = requests.post("https://httpbin.ceshiren.com/post",
files={"hogwarts_file": open("1.text", "rb")},
proxies = {"http": "http://127.0.0.1:8080",
"https": "http://127.0.0.1:8080"},
verify = False
)