dsxpt62448 2016-01-15 14:47
浏览 50
已采纳

通过AWS SDK for Go在Device Farm中上传的Android应用从未更改为INITIALIZED状态

I'm trying to use AWS SDK for Go to automate app runs in AWS Device Farm. But any app that uploaded with Go version of SDK never changed status from "INITIALIZED". If I upload them via AWS Console web UI, then all will be fine.

Example of code for upload: func uploadApp(client *devicefarm.DeviceFarm, appType, projectArn string) string { params := &devicefarm.CreateUploadInput{ Name: aws.String(*appName), ProjectArn: aws.String(projectArn), Type: aws.String(appType), } resp, err := client.CreateUpload(params) if err != nil { log.Fatal("Failed to upload an app because of: ", err.Error()) } log.Println("Upload ARN:", *resp.Upload.Arn) return *resp.Upload.Arn } In response I got something like:
{ Upload: { Arn: "arn:aws:devicefarm:us-west-2:091463382595:upload:c632e325-266b-4bda-a74d-0acec1e2a5ae/9fbbf140-e377-4de9-b7df-dd18a21b2bca", Created: 2016-01-15 14:27:31 +0000 UTC, Name: "app-debug-unaligned.apk", Status: "INITIALIZED", Type: "ANDROID_APP", Url: "bla-bla-bla" } }
With time status never changes from "INITIALIZED". As I mentioned, apps which run scheduled from UI works fine.

How to figure it out reason of this ?

=======================================

Solution:

1) After CreateUpload it requires to upload a file using pre-signed S3 link in the response
2) Upload should be executed via HTTP PUT request by received URL with file content in the body
3) In &devicefarm.CreateUploadInput should be specified ContentTypeparameter. For PUT request same value for Content-Type header should be used
4) If PUT request will be send from Go code, then Content-Length header should be set manually

  • 写回答

1条回答 默认 最新

  • dongyan2445 2016-01-15 19:23
    关注

    When you call the CreateUpload API, Device Farm will return an "Upload" response containing a "Url" field.

    { Upload: { Arn: "arn:aws:devicefarm:us-west-2:....", Created: 2016-01-15 14:27:31 +0000 UTC, Name: "app-name.apk", Status: "INITIALIZED", Type: "ANDROID_APP", Url: "bla-bla-bla" } }

    The returned url, "bla-bla-bla", is a pre-signed S3 url for you to upload your application. Documentation on using a pre-signed url to upload an object: http://docs.aws.amazon.com/AmazonS3/latest/dev/PresignedUrlUploadObject.html

    Once your application has been uploaded, the app will be processed. The status of your upload will change to "PROCESSING" and "SUCCEEDED" (or "FAILED" if something is wrong). Once it's in "SUCCEEDED" status, you can use it to schedule a run.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分