【发布时间】:2014-01-28 14:08:57
【问题描述】:
我想使用 Python 部署工件(使用类似于一组工件的 zip 文件,并且应该保留目录结构 - 根据文档) 当我使用以下文档时,没有任何反应(没有在 repo 中创建文件),但我得到了 OK 响应:
import httplib
import base64
import os
dir = "/home/user/"
file = "archive.zip"
localfilepath = dir + file
artifactory = "www.stg.com"
url = "/artifactory/some/repo/archive.zip"
f = open(localfilepath, 'r')
filedata = f.read()
f.close()
authheader = "Basic %s" % base64.encodestring('%s:%s' % ("my-username", "my-password"))
conn = httplib.HTTPConnection(artifactory)
conn.request('PUT', url, filedata, {"Authorization": authheader, "X-Explode-Archive": "true"})
resp = conn.getresponse()
content = resp.read()
我怎样才能让它工作?
【问题讨论】:
-
在 Artifactory 日志中的 request.log 或 access.log 中看到请求了吗?
-
我帮您解决了,文件需要以流媒体方式上传。我将使用示例代码更新我的答案。
标签: python http request put artifactory