diff --git a/apps/common/handle/impl/csv_split_handle.py b/apps/common/handle/impl/csv_split_handle.py index 11dbdc785..6a4849c67 100644 --- a/apps/common/handle/impl/csv_split_handle.py +++ b/apps/common/handle/impl/csv_split_handle.py @@ -8,6 +8,7 @@ """ import csv import io +import os from typing import List from charset_normalizer import detect @@ -28,7 +29,8 @@ class CsvSplitHandle(BaseSplitHandle): def handle(self, file, pattern_list: List, with_filter: bool, limit: int, get_buffer, save_image): buffer = get_buffer(file) paragraphs = [] - result = {'name': file.name, 'content': paragraphs} + file_name = os.path.basename(file.name) + result = {'name': file_name, 'content': paragraphs} try: reader = csv.reader(io.TextIOWrapper(io.BytesIO(buffer), encoding=detect(buffer)['encoding'])) try: diff --git a/apps/common/handle/impl/doc_split_handle.py b/apps/common/handle/impl/doc_split_handle.py index d97a8e45b..753e74fc4 100644 --- a/apps/common/handle/impl/doc_split_handle.py +++ b/apps/common/handle/impl/doc_split_handle.py @@ -7,6 +7,7 @@ @desc: """ import io +import os import re import traceback import uuid @@ -167,6 +168,7 @@ class DocSplitHandle(BaseSplitHandle): in elements]) def handle(self, file, pattern_list: List, with_filter: bool, limit: int, get_buffer, save_image): + file_name = os.path.basename(file.name) try: image_list = [] buffer = get_buffer(file) @@ -180,9 +182,9 @@ class DocSplitHandle(BaseSplitHandle): split_model = SplitModel(default_pattern_list, with_filter=with_filter, limit=limit) except BaseException as e: traceback.print_exception(e) - return {'name': file.name, + return {'name': file_name, 'content': []} - return {'name': file.name, + return {'name': file_name, 'content': split_model.parse(content) }