def save_icon(obj, icon_content, sizes=mkt.CONTENT_ICON_SIZES):
 tmp_dst = os.path.join(settings.TMP_PATH, 'icon', uuid.uuid4().hex)
 with public_storage.open(tmp_dst, 'wb') as fd:
  fd.write(icon_content)
 dirname = obj.get_icon_dir()
 destination = os.path.join(dirname, ('%s' % obj.pk))
 remove_icons(destination)
 icon_hash = resize_icon(tmp_dst, destination, sizes, set_modified_on=[obj], src_storage=public_storage, dst_storage=public_storage)
 obj.icon_hash = icon_hash['icon_hash']
 try:
  obj.icon_type = 'image/png'
 except AttributeError:
  pass
 obj.save()

def save_icon ( obj , icon_content , sizes = mkt . CONTENT_ICON_SIZES ) : tmp_dst = os . path . join ( settings . TMP_PATH , 'icon' , uuid . uuid4 ( ) . hex ) with public_storage . open ( tmp_dst , 'wb' ) as fd : fd . write ( icon_content ) dirname = obj . get_icon_dir ( ) destination = os . path . join ( dirname , ( '%s' % obj . pk ) ) remove_icons ( destination ) icon_hash = resize_icon ( tmp_dst , destination , sizes , set_modified_on = [ obj ] , src_storage = public_storage , dst_storage = public_storage ) obj . icon_hash = icon_hash [ 'icon_hash' ] try : obj . icon_type = 'image/png' except AttributeError : pass obj . save ( )
saves the icon for obj to its final destination .