Skip to content

Commit

Permalink
[Fix] Multi Doc support in prompt studio (#1078)
Browse files Browse the repository at this point in the history
* changed read length to full length

* added todo

* code refactor

---------

Co-authored-by: Gayathri <[email protected]>
  • Loading branch information
jagadeeswaran-zipstack and gaya3-zipstack authored Jan 20, 2025
1 parent 538a83d commit 02a1ac2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion backend/utils/FileValidator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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):
Expand Down Expand Up @@ -69,7 +70,10 @@ def _check_file_extension(self, file: InMemoryUploadedFile) -> None:
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:
Expand Down

0 comments on commit 02a1ac2

Please sign in to comment.