fix: 修改图片上传像素校验位200亿 (#943)
This commit is contained in:
parent
59af953caa
commit
9d3e0d4516
@ -13,13 +13,13 @@ from django.http import HttpResponse
|
|||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
from common.exception.app_exception import NotFound404
|
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 common.util.field_message import ErrMessage
|
||||||
from dataset.models import Image
|
from dataset.models import Image
|
||||||
|
|
||||||
|
|
||||||
class ImageSerializer(serializers.Serializer):
|
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):
|
def upload(self, with_valid=True):
|
||||||
if with_valid:
|
if with_valid:
|
||||||
|
|||||||
@ -3,13 +3,15 @@ import mimetypes
|
|||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
from ..const import CONFIG, PROJECT_DIR
|
from ..const import CONFIG, PROJECT_DIR
|
||||||
|
|
||||||
mimetypes.add_type("text/css", ".css", True)
|
mimetypes.add_type("text/css", ".css", True)
|
||||||
mimetypes.add_type("text/javascript", ".js", True)
|
mimetypes.add_type("text/javascript", ".js", True)
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
|
Image.MAX_IMAGE_PIXELS = 20000000000
|
||||||
# Quick-start development settings - unsuitable for production
|
# Quick-start development settings - unsuitable for production
|
||||||
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
|
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user