change in update api, added method to upload and get image url

This commit is contained in:
abutalib-kiwi
2023-08-01 20:13:35 +05:30
parent ee92c98f34
commit d3564efbb9
2 changed files with 24 additions and 29 deletions

View File

@ -1,6 +1,8 @@
"""
web_utils file
"""
from base.constants import ARTICLE_CARD_IMAGE_FOLDER
from guardian.utils import upload_image_to_alibaba
def pop_id(data):
@ -11,3 +13,12 @@ def pop_id(data):
"""
data.pop('id') if 'id' in data else data
return data
def get_image_url(data):
if 'image' in data and data['image'] is not None:
image = data.pop('image')
filename = f"{ARTICLE_CARD_IMAGE_FOLDER}/{image.name}"
# upload image on ali baba
image_url = upload_image_to_alibaba(image, filename)
return image_url