mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-11-26 08:34:55 +00:00
change in update api, added method to upload and get image url
This commit is contained in:
@ -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
|
||||
|
||||
Reference in New Issue
Block a user