【发布时间】:2018-03-02 13:42:12
【问题描述】:
我正在尝试使用 python + boto3 在设备场中创建上传(上传测试或应用程序)。方法“create_upload”工作正常,因为它返回一个上传 arn 和 url 上传到它。
当我尝试使用请求将文件上传到此 URL 时出现错误:
<Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message><AWSAccessKeyId>AKIAJV4C3CWPBUMBC3GA</AWSAccessKeyId><StringToSign>AWS4-HMAC-SHA256
我的代码:
response = client.create_upload(
projectArn=df_project,
name="test.zip",
type="APPIUM_JAVA_TESTNG_TEST_PACKAGE",
contentType='application/octet-stream'
)
test_url = response["upload"]["url"]
files = {'upload_file': open('/tmp/test.zip','rb')}
r = requests.post(test_url, files=files, data={})
我也尝试使用 curl 和 requests.post 将文件传递给数据 属性:
r = requests.put(test_url, data=open("/tmp/test.zip", "rb").read())
print(r.text)
和
cmd = "curl --request PUT --upload-file /tmp/test.zip \""+test_url+"\""
result = subprocess.call(cmd, shell=True)
print(result)
【问题讨论】:
标签: python-3.x amazon-web-services aws-device-farm