#NEWLINE# def to_internal_value( self , data ) : #NEWLINE# #INDENT# if isinstance ( data , str ) : #NEWLINE# #INDENT# if ( ( 'data:' in data ) and ( ';base64,' in data ) ) : #NEWLINE# #INDENT# ( header , data ) = data . split ( ';base64,' ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# decoded_data = base64 . b64decode ( data ) #NEWLINE# #UNINDENT# except TypeError : #NEWLINE# #INDENT# self . fail ( 'invalid_image' ) #NEWLINE# #UNINDENT# file_name = ( 'uploaded_image.' + self . guess_file_extension ( decoded_data ) ) #NEWLINE# data = ContentFile ( decoded_data , name = file_name ) #NEWLINE# #UNINDENT# return super ( ) . to_internal_value ( file_name )