rheaders = {
'XF-Api-Key': self.api_key,
'XF-Api-User': '1',
'Content-Type': 'application/x-www-form-urlencoded'
}
rfiles = {'avatar': ("avatar", open(file, 'rb'), 'image/jpeg')}
target = self.url + '/api/users/{}/avatar'.format(users[username])
try:
response = requests.post(url=target, files=rfiles, headers=rheaders)
print(response.json())
return response.json()["success"]
except:
return False