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

标签 python http post file-upload streaming

我正在尝试通过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 

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

最佳答案

您可以使用requests library :

import requests # $ pip install requests

with open("file.ova", "rb") as file:
    requests.post(url, data=file)

关于python - 如何在Python中通过HTTPPost方法发送大文件,上传大文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17722939/

相关文章:

java apache HC BasicHttpEntityEnclosingRequest 与 BasicHttpRequest

c# - 通过 HttpClient.PostAsync 的 POST 请求,主体内有 StorageFile (WinRT)

python - Flask 运行 request.method 默认为 'POST' 而不是 'GET'

perl - 为什么我的 .zip 文件在 HTTP 文件上传后损坏了?

node.js - 如何在 Node.js 中设置最大 http 客户端连接数

python - python 中的 HTTP POST Curl

python - 分配多索引列,同时保留索引级别值的顺序

python - 如何用 Python 中的另一个字符替换字符串中的一个字符?

python - 移动没有频率的时间序列?

python - 我可以将 xmodem 协议(protocol)与 PySerial 一起使用吗?