in packages/ekyc-api/src/ekyc-api/Controllers/SessionController.cs [320:371]
public async Task SubmitFaceWithNosePointing(string sessionId, string s3Key)
{
if (string.IsNullOrEmpty(sessionId))
throw new HttpStatusException(HttpStatusCode.InternalServerError, "Session ID cannot be blank.");
if (string.IsNullOrEmpty(s3Key))
throw new HttpStatusException(HttpStatusCode.InternalServerError, "S3 key cannot be blank.");
// Check if the session exists
var sessionValid = await _sessionManager.SessionExistsAndIsValid(sessionId);
if (!sessionValid)
throw new HttpStatusException(HttpStatusCode.InternalServerError,
$"Session ID {sessionId} not found or has expired.");
var config = new DynamoDBOperationConfig
{
OverrideTableName = Globals.SessionTableName
};
var item = await _dbContext.LoadAsync<SessionObject>(sessionId, config);
if (item == null) throw new HttpStatusException(HttpStatusCode.InternalServerError, "Session not found.");
var imaging = new Imaging(_amazonS3, _documentChecker);
Image img;
s3Key = sessionId + "/" + s3Key;
try
{
img = await imaging.GetImageFromStorage(s3Key);
}
catch (ImageFormatException)
{
throw new HttpStatusException(HttpStatusCode.InternalServerError, "Key provided is not a valid image.");
}
catch (Exception ex)
{
throw new HttpStatusException(HttpStatusCode.InternalServerError, ex.Message);
}
if (img == null)
throw new HttpStatusException(HttpStatusCode.InternalServerError, "Image is not valid.");
await _livenessChecker.VerifyImageSize(img);
item.nosePointImageKey = s3Key;
await _dbContext.SaveAsync(item, config);
}