def sync_headers(cloud_obj, headers=None, header_patterns=HEADER_PATTERNS):
if headers is None:<EOL><INDENT>headers = {}<EOL><DEDENT>content_type = getattr(cloud_obj, "<STR_LIT>", None)<EOL>if content_type == "<STR_LIT>":<EOL><INDENT>return<EOL><DEDENT>matched_headers = {}<EOL>for pattern, pattern_headers in header_patterns:<EOL><INDENT>if pattern.match(cloud_obj.name):<EOL><INDENT>matched_headers.update(pattern_headers.copy())<EOL><DEDENT><DEDENT>matched_headers.update(cloud_obj.headers)<EOL>matched_headers.update(headers)<EOL>if matched_headers != cloud_obj.headers:<EOL><INDENT>cloud_obj.headers = matched_headers<EOL>cloud_obj.sync_metadata()<EOL><DEDENT>
Overwrites the given cloud_obj's headers with the ones given as ``headers`
and adds additional headers as defined in the HEADERS setting depending on
the cloud_obj's file name.