Files
edx-platform/lms/djangoapps/verify_student/image.py
Will Daly 47b81c9274 Allow users to submit initial verification at in-course checkpoints.
* Combine verification and reverification photo submission end-points.
* Combine verification and reverification Backbone models.
* Allow deletion of verification status in Django admin.
* Initial verification from a checkpoint is associated with the checkpoint.
* Fix critical bug in which an invalid link was sent to Software Secure
  for the photo ID image of reverification attempts.
2015-07-27 19:32:18 -07:00

36 lines
671 B
Python

"""
Image encoding helpers for the verification app.
"""
import logging
log = logging.getLogger(__name__)
class InvalidImageData(Exception):
"""
The provided image data could not be decoded.
"""
pass
def decode_image_data(data):
"""
Decode base64-encoded image data.
Arguments:
data (str): The raw image data, base64-encoded.
Returns:
str
Raises:
InvalidImageData: The image data could not be decoded.
"""
try:
return (data.split(",")[1]).decode("base64")
except (IndexError, UnicodeEncodeError):
log.exception("Could not decode image data")
raise InvalidImageData