def sync_file(self, base, filename):
        name = filename[len(base) + 1:]
        bucket = s3_bucket()
        key = bucket.get_key(name)
        if key:
            etag = key.etag.lstrip('"').rstrip('"')
            with open(filename) as f:
                md5 = key.compute_md5(f)[0]
            if etag != md5:
                locked_print('Syncing %s' % (name,))
                set_content_type(key)
                key.set_contents_from_filename(filename, policy='public-read',
                    md5=md5, replace=True)
        else:
            locked_print('Syncing %s' % (name,))
            key = bucket.new_key(name)
            set_content_type(key)
            key.set_contents_from_filename(filename, policy='public-read',
                replace=True)
dataset/ETHPy150Open ericflo/django-simplestatic/simplestatic/management/commands/static_sync.py/Command.sync_file/original