Quantcast
Channel: Active questions tagged amazon-ec2 - Stack Overflow
Viewing all articles
Browse latest Browse all 29250

connect ec2 and rekognition in aws

$
0
0

How to remove the php fatal error?

This is the code of AWS (ec2-os-linux) to get the image in Amazon Rekognition when given to EC2.

This is the error which is occurring:

PHP Fatal error: Uncaught TypeError: Argument 1 passed to Aws\Common\Client\AbstractClient::__construct() must be an instance of Aws\Common\Credentials\CredentialsInterface, array given, called in /var/www/html/face/index.php on line 43 and defined in /var/www/html/face/vendor/aws/aws-sdk-php/src/Aws/Common/Client/AbstractClient.php:73

Stack trace: #0 /var/www/html/face/index.php(43): Aws\Common\Client\AbstractClient-> __construct(Array) #1 {main} thrown in /var/www/html/face/vendor/aws/aws-sdk-php/src/Aws/Common/Client/AbstractClient.php on line 73

My code:

require_once(__DIR__ . '/vendor/autoload.php');use Aws\S3\S3Client;use Aws\Rekognition\RekognitionClient;$bucket = 'aws-webinar-ethnus';$keyname = 's.jpg';$s3 = new S3Client(['region'    => 'us-east-2','version'   => '2006-03-01','signature' => 'v4']);try {    // Upload data.    $result = $s3->putObject(['Bucket'        => $bucket,'Key'           => $keyname,'SourceFile'    => __DIR__. "/$keyname",'ACL'           => 'public-read-write'    ]);    // Print the URL to the object.    $imageUrl = $result['ObjectURL'];    if($imageUrl) {        echo "Image upload done... Here is the URL: " . $imageUrl;        $rekognition = new RekognitionClient(['region'    => 'us-east-2','version'   => 'latest',        ]);        $result = $rekognition->detectFaces(['Attributes'    => ['DEFAULT'],'Image' => ['S3Object' => ['Bucket' => $bucket,'Name'  =>  $keyname,'Key'   =>  $keyname,                ],            ],        ]);        echo "Totally there are " . count($result["FaceDetails"]) . " faces";    }} catch (Exception $e) {    echo $e->getMessage() . PHP_EOL;}

enter image description here


Viewing all articles
Browse latest Browse all 29250

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>