requests上传文件会现在大小、
使用requests_toolbelt 不会限制大小,而且还可以获取 Content-Type,这个上传文件是要验证的,如果没有上传是失败的。
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryiSnhC3Aeyzzhqlyt # ----WebKitFormBoundaryiSnhC3Aeyzzhqlyt 这个就是内容分隔符
如果请求头有类似,应该使用requests_toolbelt 上传,
具体用法:
from requests_toolbelt import MultipartEncoder
m = MultipartEncoder(
fields={'media': ('blob', _pic_f.read(),
'application/octet-stream')}
)
字段分别为 name filename content(二进制数据),Content-Type(这边为数据流)
headers['Content-Type'] = m.content_type