How send base64 image to front-end?
Hello!
I'm using Amplify + Aws Rekognition + FaceLiveness and i have a problem in this method:
GetFaceLivenessSessionResults
{
"AuditImages": [
{
"BoundingBox": {
"Height": number,
"Left": number,
"Top": number,
"Width": number
},
"Bytes": blob,
"S3Object": {
"Bucket": "string",
"Name": "string",
"Version": "string"
}
}
],
"Confidence": number,
"ReferenceImage": {
"BoundingBox": {
"Height": number,
"Left": number,
"Top": number,
"Width": number
},
"Bytes": blob,
"S3Object": {
"Bucket": "string",
"Name": "string",
"Version": "string"
}
},
"SessionId": "string",
"Status": "string"
}
Using the Amplify front+backend, i can just get the data correctly, but i'm using a back-end in Laravel and just using the components for Liveness Service in front-end.
This code below is my code to get the results of the LivenessSession, and when i send it to front-end, i have this error in ReferenceImage/Bytes key:
Malformed UTF-8 characters, possibly incorrectly encoded
public function getResults($sessionId) {
try {
$client = new RekognitionClient([
'region' => 'us-east-1',
'version' => 'latest',
'credentials' => [
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY')
]
]);
$results = $client->getFaceLivenessSessionResults([
'SessionId' => $sessionId
]);
unset($results['@metadata']);
unset($results['AuditImages']);
return response()->json([
'status' => 'success',
'data' => $results->toArray()
]);
} catch (AwsException $error) {
return response()->json([
'status' => 'error',
'message' => 'AWS Error: ' . $error->getAwsErrorMessage()
], $error->getStatusCode());
} catch (\Exception $error) {
return response()->json([
'status' => 'error',
'message' => 'General Error: ' . $error->getMessage()
], 500);
}
}
This is the type of the key:
Bytes The Base64-encoded bytes representing an image selected from the Face Liveness video and returned for audit purposes.
Type: Base64-encoded binary data object
Length Constraints: Minimum length of 1. Maximum length of 204800.
Required: No
And i already used base64_encode, decode, utf8 encode and decode and don't can just send the image to the front-end, i really will be grateful if anyone help me! :)
Please or to participate in this conversation.