1、带证书上传文件
filename = ‘/tmp/test.cert‘
hash_v = ‘assumethisisahash‘
#这是一种流式上传的方式
with open(filename, ‘rb‘) as f:
....requests.post(link, data={‘hash‘: hash_v}, files={‘filename‘:f}, verify=‘/tmp/test.cert‘)
2、最简单的流式上传
with open(‘massive-body‘) as f: requests.post(‘http://some.url/streamed‘, data=f)
3、块编码请求
def gen(): yield ‘hi‘ yield ‘there‘ requests.post(‘http://some.url/chunked‘, data=gen())
其他内容可参见:http://www.ziliao1.com/Article/Show/05534046411C9B8866742DE312F126CB.html
时间: 2024-10-27 07:25:56