def save_and_validate_logo(logo_stream, logo_filename, community_id):
cfg = current_app.config<EOL>logos_bucket_id = cfg['<STR_LIT>']<EOL>logo_max_size = cfg['<STR_LIT>']<EOL>logos_bucket = Bucket.query.get(logos_bucket_id)<EOL>ext = os.path.splitext(logo_filename)[<NUM_LIT:1>]<EOL>ext = ext[<NUM_LIT:1>:] if ext.startswith('<STR_LIT:.>') else ext<EOL>logo_stream.seek(SEEK_SET, SEEK_END)  <EOL>logo_size = logo_stream.tell()<EOL>if logo_size > logo_max_size:<EOL><INDENT>return None<EOL><DEDENT>if ext in cfg['<STR_LIT>']:<EOL><INDENT>key = "<STR_LIT>".format(community_id, ext)<EOL>logo_stream.seek(<NUM_LIT:0>)  <EOL>ObjectVersion.create(logos_bucket, key, stream=logo_stream,<EOL>size=logo_size)<EOL>return ext<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>
Validate if communities logo is in limit size and save it.