mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-16 02:16:16 +00:00
check size of the image
This commit is contained in:
@ -3,12 +3,14 @@ from rest_framework import viewsets, status, generics,views
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
from rest_framework.pagination import PageNumberPagination
|
||||
from rest_framework.response import Response
|
||||
from PIL import Image
|
||||
"""Django app import"""
|
||||
from junior.models import Junior
|
||||
from .serializers import (CreateJuniorSerializer, JuniorDetailListSerializer, AddJuniorSerializer,\
|
||||
RemoveJuniorSerializer)
|
||||
from guardian.models import Guardian
|
||||
from base.messages import ERROR_CODE, SUCCESS_CODE
|
||||
from base.constants import NUMBER
|
||||
from account.utils import custom_response, custom_error_response
|
||||
from guardian.utils import upload_image_to_alibaba
|
||||
# Create your views here.
|
||||
@ -23,6 +25,10 @@ class UpdateJuniorProfile(viewsets.ViewSet):
|
||||
request_data = request.data
|
||||
image = request.data.get('image')
|
||||
image_url = ''
|
||||
img = Image.open(image)
|
||||
width, height = img.size
|
||||
if width == NUMBER['zero'] or height == NUMBER['zero']:
|
||||
return custom_error_response(ERROR_CODE['2035'], response_status=status.HTTP_400_BAD_REQUEST)
|
||||
if image:
|
||||
filename = f"images/{image.name}"
|
||||
image_url = upload_image_to_alibaba(image, filename)
|
||||
|
Reference in New Issue
Block a user