我想在设备农场(上传测试或应用程序)中使用python + boto3创建上传。 “create_upload”方法可以正常工作,因为它返回一个上传的arn和url以上传到它。上传文件到AWS设备农场
当我尝试使用要求上传文件到这个网址我得到一个错误:
<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传递文件将数据 attribut:
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)