I'm getting below error when I execute Rekognition using Image or Video (s3 source).
" Error executing "SearchFacesByImage" on "https://rekognition.us-east-1.amazonaws.com"; AWS HTTP error: Client error: POST https://rekognition.us-east-1.amazonaws.com resulted in a 400 Bad Request response: {"__type":"InvalidS3ObjectException","Code":"InvalidS3ObjectException","Logref":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"," (truncated...) InvalidS3ObjectException (client): Unable to get object metadata from S3. Check object key, region and/or access permissions. - {"__type":"InvalidS3ObjectException","Code":"InvalidS3ObjectException.
My as code Below.
$credentials = new Credentials('xxxxxxxxx', 'xxxxxxxxxxxx');
$rekognitionClient = RekognitionClient::factory(array(
'region' => "us-east-1",
'version' => 'latest',
'credentials' => $credentials,
'http' => [ 'verify' => false ]
));
$result = $rekognitionClient->searchFacesByImage([
'CollectionId' => ''.$collection_id.'', // REQUIRED
'FaceMatchThreshold' => 25.0,
'Image' => [ // REQUIRED
'S3Object' => [
'Bucket' => 'facetracking',
'Name' => 'test.jpg',
'Key' => 'test.jpg',
'Version' => 'latest',
],
], 'MaxFaces' => 2,
]);
When I'm uploading into S3, Getting an object from S3 and creating a collection in Rekognition All Its works fine but I can't execute searchFacesByImage (Source: S3) and startFaceSearch in Laravel PHP.
Also tired after bucket policy setup in S3 like below.
{
"Version": "2012-10-17",
"Id": "PolicyXXXXXX",
"Statement": [
{
"Sid": "StmtXXXXXX",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::XXXXXXXX:root"
},
"Action": [
"s3:GetObject",
"s3:GetObjectAcl",
"s3:GetObjectTagging",
"s3:GetObjectTorrent",
"s3:GetObjectVersion",
"s3:GetObjectVersionAcl"
],
"Resource": [
"arn:aws:s3:::<MyBucketName>/*",
"arn:aws:s3:::<MyBucketName>"
]
}
]
}