#998 Fix a bug in uploading avatars