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 CARSIM前车变道设置
  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败