fix: 修改图片上传像素校验位200亿 (#943)

This commit is contained in:
shaohuzhang1 2024-08-07 14:28:08 +08:00 committed by GitHub
parent 59af953caa
commit 9d3e0d4516
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View File

@ -13,13 +13,13 @@ from django.http import HttpResponse
from rest_framework import serializers
from common.exception.app_exception import NotFound404
from common.field.common import UploadedFileField
from common.field.common import UploadedImageField
from common.util.field_message import ErrMessage
from dataset.models import Image
class ImageSerializer(serializers.Serializer):
image = UploadedFileField(required=True, error_messages=ErrMessage.file("图片"))
image = UploadedImageField(required=True, error_messages=ErrMessage.image("图片"))
def upload(self, with_valid=True):
if with_valid:

View File

@ -3,13 +3,15 @@ import mimetypes
import os
from pathlib import Path
from PIL import Image
from ..const import CONFIG, PROJECT_DIR
mimetypes.add_type("text/css", ".css", True)
mimetypes.add_type("text/javascript", ".js", True)
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
Image.MAX_IMAGE_PIXELS = 20000000000
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/