我正在尝试使用 bash 脚本将 apk 上传到设备场,我已使用 create-upload 端点获取 put 请求的预签名 url,然后我使用 curl 将 apk 放置到端点。
RESPONSE=$(aws devicefarm create-upload --project-arn %deviceFarmProjectARN% --name platforms/android/build/outputs/apk/android-release-unsigned.apk --type ANDROID_APP --content-type application/octet-stream)
APK_ARN=$(echo "$RESPONSE" | grep arn:aws:devicefarm | gawk 'match($0, "(arn:aws:devicefarm(.*))\"", ary) {print ary[1]}')
APK_PUT_URL=$(echo "$RESPONSE" | gawk 'match($0, "\"url\": \"(.*)\"", ary) {print ary[1]}')
echo "$APK_ARN" >> apkARN.txt
curl $APK_PUT_URL -X PUT --upload-file platforms/android/build/outputs/apk/android-release-unsigned.apk -H "Content-Type:application/octet-stream"
文件上传似乎有效,但是当我使用返回的 ARN 检查状态时,状态失败,原因是“上传的应用程序无效”
"upload": {
"status": "FAILED",
"contentType": "application/octet-stream",
"name": "platforms/android/build/outputs/apk/android-release-unsigned.apk",
"created": 1437582538.139,
"type": "ANDROID_APP",
"arn": "arn:aws:devicefarm:us-west-2:208791684493:upload:a9153182-8e03-4bc3-a5db-bc02034f1331/190ac7a5-bdc4-46f2-aac2-46bb994f2cf3",
"metadata": "{\"errorMessage\":\"Invalid application uploaded.\"}"
}
但是,当我通过 GUI 在 Web 控制台上上传完全相同的文件时,应用程序很好,我可以针对它运行测试。