Answer the question
In order to leave comments, you need to log in
Getting an error when uploading a photo using urlilib?
Why do I get an error when uploading photos with wget? I have been using it for a long time and nothing like this happened.
What is the reason for this and how to solve the problem?
PS opens without problems
https://cdn-images-1.medium.com/fit/c/200/200/1*dm... "
def download(url, path, token):
if not os.path.exists(path):
os.makedirs(path)
try:
user = UserProfile.objects.get(token=token)
name = wget.detect_filename(url)
# file_extension = os.path.splitext(name)[1]
file_extension =check_extension(name)
file_path = path + '/' + str(user.id) +'_' + '0' + file_extension
if os.path.exists(file_path):
os.remove(file_path)
filename = wget.download(url, file_path)
file_http = site_url + 'static/' + str(user.id) + '/' + str(user.id) + '_' + '0' + file_extension
return file_http
except Exception as e:
return False
self.user.photo = download(resp.get('imageUrl'), upload_dir + str(self.user.id), self.user.token)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question