From 522820234bfbec65736f85dc4d453ed3d4b207ed Mon Sep 17 00:00:00 2001 From: LeandroJatai Date: Tue, 22 Nov 2022 17:57:00 -0300 Subject: [PATCH] hotfix: alt validator file para testar memory e temporary files --- sapl/utils.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sapl/utils.py b/sapl/utils.py index 88eba024c..0770b4e15 100644 --- a/sapl/utils.py +++ b/sapl/utils.py @@ -22,7 +22,8 @@ from django.contrib.contenttypes.fields import (GenericForeignKey, GenericRel, GenericRelation) from django.core.exceptions import ValidationError from django.core.files.storage import FileSystemStorage -from django.core.files.uploadedfile import UploadedFile +from django.core.files.uploadedfile import UploadedFile, InMemoryUploadedFile,\ + TemporaryUploadedFile from django.core.mail import get_connection from django.db import models from django.db.models import Q @@ -611,7 +612,12 @@ TIPOS_IMG_PERMITIDOS = ( def fabrica_validador_de_tipos_de_arquivo(lista, nome): def restringe_tipos_de_arquivo(value): - if not os.path.splitext(value.path)[1][:1]: + + filename = value.name if type(value) in ( + InMemoryUploadedFile, TemporaryUploadedFile + ) else value.path + + if not os.path.splitext(filename)[1][:1]: raise ValidationError(_( 'Não é possível fazer upload de arquivos sem extensão.')) try: