如何在Python中通过HTTPPost方法发送大文件,上传大文件

cha*_*ddy 2 python streaming post file-upload http

我想通过 Python 中的 HTTPPost 方法发布巨大的 .ova 文件

**ResponseHeaders**
Pragma  no-cache
Date    Thu, 18 Jul 2013 11:17:13 GMT
Content-Encoding    gzip
Vary    Accept-Encoding
Server  Apache-Coyote/1.1
Transfer-Encoding   chunked
Content-Language    en-US
Content-Type    application/json;charset=UTF-8
Cache-Control   no-cache, no-store, max-age=0
Expires Thu, 01 Jan 1970 00:00:00 GMT
**RequestHeaders**
Content-Type    application/json
Accept  application/json
xyzAPIVersion   1.0
X-Requested-With    XMLHttpRequest 
Run Code Online (Sandbox Code Playgroud)

如何通过 REST API 通过 HTTPPost 方法发送如此巨大的文件(500 MB)。

jfs*_*jfs 5

您可以使用requests

import requests # $ pip install requests

with open("file.ova", "rb") as file:
    requests.post(url, data=file)
Run Code Online (Sandbox Code Playgroud)