in src/textract/extract-idcard/handler.py [0:0]
def analyze_id(inputRequest:InputRequest)->dict:
'''
Analyze the image using Amazon Textract.
'''
try:
response = textract_client.analyze_id(
DocumentPages=[
{'Bytes': inputRequest.idcard_image_bytes},
])
return response
except textract_client.exceptions.UnsupportedDocumentException:
logger.error('User %s provided an invalid document.' % inputRequest.user_id)
raise InvalidImageError('UnsupportedDocument')
except textract_client.exceptions.DocumentTooLargeException:
logger.error('User %s provided document too large.' % inputRequest.user_id)
raise InvalidImageError('DocumentTooLarge')
except textract_client.exceptions.ProvisionedThroughputExceededException:
logger.error('Textract throughput exceeded.')
raise InvalidImageError('ProvisionedThroughputExceeded')
except textract_client.exceptions.ThrottlingException:
logger.error('Textract throughput exceeded.')
raise InvalidImageError('ThrottlingException')
except textract_client.exceptions.InternalServerError:
logger.error('Textract Internal Server Error.')
raise InvalidImageError('ProvisionedThroughputExceeded')