diff --git a/src/base/util/util.py b/src/base/util/util.py index bf500fa..fe1acc3 100644 --- a/src/base/util/util.py +++ b/src/base/util/util.py @@ -462,3 +462,5 @@ class Util: return desktop_env + + diff --git a/src/plugins/file-management/get_file_content.py b/src/plugins/file-management/get_file_content.py index eaf251a..ee19cf5 100644 --- a/src/plugins/file-management/get_file_content.py +++ b/src/plugins/file-management/get_file_content.py @@ -23,21 +23,30 @@ class GetFileContent(AbstractPlugin): if self.is_exist(file_path): self.logger.info("File exists: " + file_path) is_file_exists = True - file_content = self.read_file(file_path) - self.context.create_response(code=self.message_code.TASK_PROCESSED.value, - message='Dosya içeriği başarıyla alındı..', - data=json.dumps({'file_exists': is_file_exists, 'file_content': file_content}), - content_type=self.get_content_type().APPLICATION_JSON.value) + # if the file size is less than 5K + file_size = self.get_size(file_path) / 1024 + if file_size <= 5: + file_content = self.read_file(file_path) + self.context.create_response(code=self.message_code.TASK_PROCESSED.value, + message='Dosya içeriği başarıyla alındı..', + data=json.dumps({'file_exists': is_file_exists, 'file_content': file_content}), + content_type=self.get_content_type().APPLICATION_JSON.value) + else: + self.logger.error("File size is too large. File Size: {0}K ".format(str(file_size))) + self.context.create_response(code=self.message_code.TASK_ERROR.value, + message='Dosya içeriği getirilemedi. Dosya boyutu çok büyük.', + content_type=self.get_content_type().APPLICATION_JSON.value) + else: self.context.create_response(code=self.message_code.TASK_PROCESSED.value, message='Dosya bulunamadı..', content_type=self.get_content_type().APPLICATION_JSON.value) + except Exception as e: self.logger.error(str(e)) self.context.create_response(code=self.message_code.TASK_ERROR.value, message='Dosya içeriği alınırken hata oluştu: {0}'.format(str(e))) - def handle_task(task, context): plugin = GetFileContent(task, context) plugin.handle_task()