我正在使用AWS JAVA SDK自动调用设备群。我已经成功创建了项目,创建了上传并生成了S3预签名网址,但现在我必须使用这个预先签名的网址发送IPA文件。
这是我的代码,请让我知道我做错了什么。我想我不是以正确的方式将文件发送到服务器。请分享使用预先签名的网址发送文件的代码示例。我已经尝试了许多不同的方法将文件发送到设备场。
任何帮助将不胜感激。
AWSCredentials awsCredentials=new BasicAWSCredentials("sampleJRMSWANJS5KQ","sampleUSNnuC/fVSgvR9DSVr");
AWSDeviceFarm deviceFarmObj = new AWSDeviceFarmClient(awsCredentials);
CreateProjectRequest projReqObj = new CreateProjectRequest();
projReqObj.setName("JAVAHTTPAWSAPIPROJECT");
Project projObj = deviceFarmObj.createProject(projReqObj).getProject();
String projArn=projObj.getArn();
byte[] array = Files.readAllBytes(new File("/Users/abc/Documents/Card/Blue.ipa").toPath());
String data = new String(array,"UTF-8");
char[] charFile= data.toCharArray();
URL urlPreSigned = new URL(url);
HttpURLConnection connection=(HttpURLConnection)urlPreSigned.openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("PUT");
OutputStreamWriter out = new OutputStreamWriter(
connection.getOutputStream());
out.write(charFile);
out.close();
int responseCode = connection.getResponseCode();
System.out.println("Service returned response code " + responseCode);
答案 0 :(得分:2)
以下是从Device Farm Jenkins插件上传应用程序的代码参考。 https://github.com/awslabs/aws-device-farm-jenkins-plugin/blob/master/src/main/java/org/jenkinsci/plugins/awsdevicefarm/AWSDeviceFarm.java#L367
如果您需要任何其他信息,请告知我们