需要使用Artifactory REST API从Artifactory下载artefact。请求GET不完全保存文件
我的代码是:
with open(jfrog_testfile, 'wb') as outfile:
data = requests.get(baseurl, auth=(jfrog_user, jfrog_pswd), stream=True)
shutil.copyfileobj(data.raw, outfile)
data.raise_for_status()
而另一次尝试用相同的结果:
with open(jfrog_testfile, 'wb') as outfile:
data = requests.get(baseurl, auth=(jfrog_user, jfrog_pswd), stream=True)
for chunk in data.iter_content(65536):
outfile.write(chunk)
data.raise_for_status()
baseurl
是正确的,即:
baseurl = os.path.join(jfrog_url, jfrog_api, jfrog_repo, jfrog_tetstdir, jfrog_testfile)
print(baseurl)
回报:
https://project.artifactoryonline.com/project/api/storage/project-releases-local/ppp/artefact.war
问题是 - 这正是假象大小为5.7 MB,但reqeust后 - 我只拿到了841个字节:
$ ls -l artefact.war
-rw-r--r-- 1 username staff 841 Jan 21 11:47 artefact.war
即使我跑同样的要求与curl -o
- 我有相同的841个字节。 使用wget
- 我有整个文件,5,7 MB。 (e)y请求有什么不对?