def from_b64(path, bcontent, format):
decoders = {<EOL>'<STR_LIT>': lambda path, bcontent: (bcontent.decode('<STR_LIT:ascii>'), '<STR_LIT>'),<EOL>'<STR_LIT:text>': _decode_text_from_base64,<EOL>None: _decode_unknown_from_base64,<EOL>}<EOL>try:<EOL><INDENT>content, real_format = decoders[format](path, bcontent)<EOL><DEDENT>except HTTPError:<EOL><INDENT>raise<EOL><DEDENT>except Exception as e:<EOL><INDENT>raise CorruptedFile(e)<EOL><DEDENT>default_mimes = {<EOL>'<STR_LIT:text>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>}<EOL>mimetype = mimetypes.guess_type(path)[<NUM_LIT:0>] or default_mimes[real_format]<EOL>return content, real_format, mimetype<EOL>
Decode base64 content for a file.

format:
  If 'text', the contents will be decoded as UTF-8.
  If 'base64', do nothing.
  If not specified, try to decode as UTF-8, and fall back to base64

Returns a triple of decoded_content, format, and mimetype.