Skip to content

Commit bd71ca9

Browse files
committed
fix: update is_valid method to use dynamic file size limit from Knowledge model
1 parent d24532d commit bd71ca9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

apps/knowledge/serializers/document.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,11 +590,12 @@ class Split(serializers.Serializer):
590590
def is_valid(self, *, instance=None, raise_exception=True):
591591
super().is_valid(raise_exception=True)
592592
files = instance.get('file')
593+
knowledge = Knowledge.objects.filter(id=self.data.get('knowledge_id')).first()
593594
for f in files:
594-
if f.size > 1024 * 1024 * 100:
595+
if f.size > 1024 * 1024 * knowledge.file_size_limit:
595596
raise AppApiException(500, _(
596597
'The maximum size of the uploaded file cannot exceed {}MB'
597-
).format(100))
598+
).format(knowledge.file_size_limit))
598599

599600
def parse(self, instance):
600601
self.is_valid(instance=instance, raise_exception=True)

0 commit comments

Comments
 (0)