1
我一直在玩亞馬遜的新rekognition API,並且無法從IntelliJ運行它們的example Java應用程序。我在我的pom.xml
使用Maven構建項目,幷包括AWS SDK如下:無法連接到來自IntelliJ的AWS rekognition API
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>${aws-java-sdk.version}</version>
</dependency>
從我可以告訴,我的應用程序似乎是某處在這裏失敗:
AmazonRekognitionClient rekognitionClient = new AmazonRekognitionClient(credentials)
.withEndpoint("s3-us-west-2.amazonaws.com");
rekognitionClient.setSignerRegionOverride("us-west-2");
try {
DetectFacesResult result = rekognitionClient.detectFaces(request);
ObjectMapper objectMapper = new ObjectMapper();
System.out.println("Result = " + objectMapper.writeValueAsString(result));
} catch (AmazonRekognitionException e) {
e.printStackTrace();
}
...那我得到的錯誤是:
com.amazonaws.services.rekognition.model.AmazonRekognitionException: null (Service: AmazonRekognition; Status Code: 400; Error Code: null; Request ID: null)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1545)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1183)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:964)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:676)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:650)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:633)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$300(AmazonHttpClient.java:601)
at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:583)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:447)
at com.amazonaws.services.rekognition.AmazonRekognitionClient.doInvoke(AmazonRekognitionClient.java:1130)
at com.amazonaws.services.rekognition.AmazonRekognitionClient.invoke(AmazonRekognitionClient.java:1106)
at com.amazonaws.services.rekognition.AmazonRekognitionClient.detectFaces(AmazonRekognitionClient.java:599)
at com.github.jhenningsgaard.DetectFaces.main(DetectFaces.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
我也應該注意到,我跑在AWS CLI操作(見下文)和成功。
aws rekognition detect-faces \
--image '{"S3Object":{"Bucket":"Bucketname","Name":"s3ObjectKey"}}' \
--attributes "ALL" \
--region us-east-1 \
--profile adminuser
你能告訴你的'request'? –
我的請求:'{Image:{S3Object:{Bucket:rekognitionexample,Name:obama.jpg,}},Attributes:[ALL]}' –
你爲什麼試圖使用S3端點連接到rekognition服務?您應該使用重新識別端點...請參閱http://docs.aws.amazon.com/general/latest/gr/rande.html#rekognition_region – mickzer