我想在設備農場(上傳測試或應用程序)中使用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)