import requests
odxvchsauth = <src_authcode> # source authcode (parsed as header)
session_ID = <dest_authcode> # destination authcode (parsed as header)
srcurl = "https://us-texas-1-14.vchs.vmware.com/api/compute/transfer/75b72a35-e0c1-4f50-a728-bd01fc311c09/file"
desturl = "https://66.70.145.232:443/cls/data/19dcf53b-d98d-41f7-be78-853f2f85e145/test.iso"
def upload():
srcget = requests.get(srcurl, stream = True, headers = = {'Accept': 'application/*+xml;version=5.7', 'x-vcloud-authorization': odxvchsauth})
for chunk in srcget.iter_content(chunksize = 1048576):
uploadput = requests.put(desturl, data = chunk, stream = True, {'vmware-api-session-id': session_ID, 'Accept': 'application/json', 'Content-Type': 'application/octet-stream'}
upload()
我正在尝试从URL下载二进制文件的内容,并将其直接上传到目标网址。如果我使用1MB文件,则上传完成,但如果我使用大文件,则上传永远不会完成。有什么想法吗?