diff --git a/apps/common/handle/impl/qa/xlsx_parse_qa_handle.py b/apps/common/handle/impl/qa/xlsx_parse_qa_handle.py index ecadb5139..287fb9cda 100644 --- a/apps/common/handle/impl/qa/xlsx_parse_qa_handle.py +++ b/apps/common/handle/impl/qa/xlsx_parse_qa_handle.py @@ -37,7 +37,7 @@ def handle_sheet(file_name, sheet, image_dict): content = str(content.value) image = image_dict.get(content, None) if image is not None: - content = f'![](/api/image/{image.id})' + content = f'![](/oss/file/{image.id})' paragraph_list.append({'title': title[0:255], 'content': content[0:102400], 'problem_list': problem_list}) diff --git a/apps/common/handle/impl/qa/zip_parse_qa_handle.py b/apps/common/handle/impl/qa/zip_parse_qa_handle.py index af44b809c..0fa72fe3e 100644 --- a/apps/common/handle/impl/qa/zip_parse_qa_handle.py +++ b/apps/common/handle/impl/qa/zip_parse_qa_handle.py @@ -90,20 +90,20 @@ def get_image_list(result_list: list, zip_files: List[str]): '/') else source_image_path) if not zip_files.__contains__(image_path): continue - if image_path.startswith('api/file/') or image_path.startswith('api/image/'): - image_id = image_path.replace('api/file/', '').replace('api/image/', '') + if image_path.startswith('oss/file/') or image_path.startswith('oss/image/'): + image_id = image_path.replace('oss/file/', '') if is_valid_uuid(image_id): image_file_list.append({'source_file': image_path, 'image_id': image_id}) else: image_file_list.append({'source_file': image_path, 'image_id': new_image_id}) - content = content.replace(source_image_path, f'/api/image/{new_image_id}') + content = content.replace(source_image_path, f'/oss/file/{new_image_id}') p['content'] = content else: image_file_list.append({'source_file': image_path, 'image_id': new_image_id}) - content = content.replace(source_image_path, f'/api/image/{new_image_id}') + content = content.replace(source_image_path, f'/oss/file/{new_image_id}') p['content'] = content return image_file_list diff --git a/apps/common/handle/impl/table/xlsx_parse_table_handle.py b/apps/common/handle/impl/table/xlsx_parse_table_handle.py index 65188e71b..6b1a14645 100644 --- a/apps/common/handle/impl/table/xlsx_parse_table_handle.py +++ b/apps/common/handle/impl/table/xlsx_parse_table_handle.py @@ -43,7 +43,7 @@ class XlsxParseTableHandle(BaseParseTableHandle): image = image_dict.get(cell_value, None) if image is not None: - cell_value = f'![](/api/image/{image.id})' + cell_value = f'![](/oss/file/{image.id})' # 使用标题作为键,单元格的值作为值存入字典 row_data[headers[col_idx]] = cell_value @@ -110,7 +110,6 @@ class XlsxParseTableHandle(BaseParseTableHandle): md_tables += md_table + '\n\n' - md_tables = md_tables.replace('/api/image/', '/oss/file/') return md_tables except Exception as e: max_kb.error(f'excel split handle error: {e}') diff --git a/apps/common/handle/impl/text/doc_split_handle.py b/apps/common/handle/impl/text/doc_split_handle.py index a67bc5f8f..740f37c6c 100644 --- a/apps/common/handle/impl/text/doc_split_handle.py +++ b/apps/common/handle/impl/text/doc_split_handle.py @@ -43,7 +43,7 @@ def image_to_mode(image, doc: Document, images_list, get_image_id): if len([i for i in images_list if i.id == image_uuid]) == 0: image = File(id=image_uuid, file_name=part.filename, meta={'debug': False, 'content': part.blob}) images_list.append(image) - return f'![](/api/image/{image_uuid})' + return f'![](/oss/file/{image_uuid})' return None return None @@ -226,7 +226,6 @@ class DocSplitHandle(BaseSplitHandle): doc = Document(io.BytesIO(buffer)) content = self.to_md(doc, image_list, get_image_id_func()) if len(image_list) > 0: - content = content.replace('/api/image/', '/oss/file/') save_image(image_list) return content except BaseException as e: diff --git a/apps/common/handle/impl/text/xlsx_split_handle.py b/apps/common/handle/impl/text/xlsx_split_handle.py index abda06d2e..06d6f604c 100644 --- a/apps/common/handle/impl/text/xlsx_split_handle.py +++ b/apps/common/handle/impl/text/xlsx_split_handle.py @@ -18,7 +18,7 @@ from common.handle.impl.common_handle import xlsx_embed_cells_images def post_cell(image_dict, cell_value): image = image_dict.get(cell_value, None) if image is not None: - return f'![](/api/image/{image.id})' + return f'![](/oss/file/{image.id})' return cell_value.replace('\n', '
').replace('|', '|') diff --git a/apps/knowledge/serializers/common.py b/apps/knowledge/serializers/common.py index 3499ada4e..b8551bb00 100644 --- a/apps/knowledge/serializers/common.py +++ b/apps/knowledge/serializers/common.py @@ -181,20 +181,6 @@ def write_image(zip_path: str, image_list: List[str]): os.makedirs(os.path.dirname(file_path)) with open(os.path.join(zip_path, file_path), 'wb') as f: f.write(file.get_bytes()) - # else: - # r = text.replace('(/api/image/', '').replace(')', '') - # r = r.strip().split(" ")[0] - # if not is_valid_uuid(r): - # break - # image_model = QuerySet(Image).filter(id=r).first() - # if image_model is None: - # break - # zip_inner_path = os.path.join('api', 'image', r) - # file_path = os.path.join(zip_path, zip_inner_path) - # if not os.path.exists(os.path.dirname(file_path)): - # os.makedirs(os.path.dirname(file_path)) - # with open(file_path, 'wb') as f: - # f.write(image_model.image) def update_document_char_length(document_id: str): @@ -223,7 +209,6 @@ def or_get(exists_problem_list, content, knowledge_id, document_id, paragraph_id return problem, document_id, paragraph_id - def get_knowledge_operation_object(knowledge_id: str): knowledge_model = QuerySet(model=Knowledge).filter(id=knowledge_id).first() if knowledge_model is not None: