def file_to_attachment(filename, filehandler=None):
if filehandler:<EOL><INDENT>return {'<STR_LIT>': filename,<EOL>'<STR_LIT:content>': base64.b64encode(filehandler.read())<EOL>}<EOL><DEDENT>with open(filename, '<STR_LIT:rb>') as _file:<EOL><INDENT>return {'<STR_LIT>': filename,<EOL>'<STR_LIT:content>': base64.b64encode(_file.read())<EOL>}<EOL><DEDENT>
Convert a file to attachment