Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

[Fix] Multi Doc support in prompt studio (#1078)

jagadeeswaran-zipstack02a1ac221a44
diff --git a/backend/utils/FileValidator.py b/backend/utils/FileValidator.py
index 173e41f84..7b715a22e 100644
--- a/backend/utils/FileValidator.py
+++ b/backend/utils/FileValidator.py
@@ -8,6 +8,7 @@ from django.core.files.uploadedfile import InMemoryUploadedFile
from django.template.defaultfilters import filesizeformat
from django.utils.translation import gettext_lazy as _
from typing_extensions import NotRequired, Unpack
+from unstract.sdk.file_storage.constants import FileOperationParams
class FileValidationParam(TypedDict):
@@ -69,7 +70,10 @@ class FileValidator:
raise ValidationError(message)
def _check_file_mime_type(self, file: InMemoryUploadedFile) -> None:
- mimetype = magic.from_buffer(file.read(2048), mime=True)
+ # TODO: Need to optimise, istead of reading entire file.
+ mimetype = magic.from_buffer(
+ file.read(FileOperationParams.READ_ENTIRE_LENGTH), mime=True
+ )
file.seek(0) # Reset the file pointer to the start
if self.allowed_mimetypes and mimetype not in self.allowed_mimetypes: