Skip to content

Commit 9a72812

Browse files
committed
fix: update image URL paths to use OSS endpoints
1 parent e5e9939 commit 9a72812

File tree

6 files changed

+8
-25
lines changed

6 files changed

+8
-25
lines changed

apps/common/handle/impl/qa/xlsx_parse_qa_handle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def handle_sheet(file_name, sheet, image_dict):
3737
content = str(content.value)
3838
image = image_dict.get(content, None)
3939
if image is not None:
40-
content = f'![](/api/image/{image.id})'
40+
content = f'![](/oss/file/{image.id})'
4141
paragraph_list.append({'title': title[0:255],
4242
'content': content[0:102400],
4343
'problem_list': problem_list})

apps/common/handle/impl/qa/zip_parse_qa_handle.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,20 @@ def get_image_list(result_list: list, zip_files: List[str]):
9090
'/') else source_image_path)
9191
if not zip_files.__contains__(image_path):
9292
continue
93-
if image_path.startswith('api/file/') or image_path.startswith('api/image/'):
94-
image_id = image_path.replace('api/file/', '').replace('api/image/', '')
93+
if image_path.startswith('oss/file/') or image_path.startswith('oss/image/'):
94+
image_id = image_path.replace('oss/file/', '')
9595
if is_valid_uuid(image_id):
9696
image_file_list.append({'source_file': image_path,
9797
'image_id': image_id})
9898
else:
9999
image_file_list.append({'source_file': image_path,
100100
'image_id': new_image_id})
101-
content = content.replace(source_image_path, f'/api/image/{new_image_id}')
101+
content = content.replace(source_image_path, f'/oss/file/{new_image_id}')
102102
p['content'] = content
103103
else:
104104
image_file_list.append({'source_file': image_path,
105105
'image_id': new_image_id})
106-
content = content.replace(source_image_path, f'/api/image/{new_image_id}')
106+
content = content.replace(source_image_path, f'/oss/file/{new_image_id}')
107107
p['content'] = content
108108

109109
return image_file_list

apps/common/handle/impl/table/xlsx_parse_table_handle.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def fill_merged_cells(self, sheet, image_dict):
4343

4444
image = image_dict.get(cell_value, None)
4545
if image is not None:
46-
cell_value = f'![](/api/image/{image.id})'
46+
cell_value = f'![](/oss/file/{image.id})'
4747

4848
# 使用标题作为键,单元格的值作为值存入字典
4949
row_data[headers[col_idx]] = cell_value
@@ -110,7 +110,6 @@ def get_content(self, file, save_image):
110110

111111
md_tables += md_table + '\n\n'
112112

113-
md_tables = md_tables.replace('/api/image/', '/oss/file/')
114113
return md_tables
115114
except Exception as e:
116115
max_kb.error(f'excel split handle error: {e}')

apps/common/handle/impl/text/doc_split_handle.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def image_to_mode(image, doc: Document, images_list, get_image_id):
4343
if len([i for i in images_list if i.id == image_uuid]) == 0:
4444
image = File(id=image_uuid, file_name=part.filename, meta={'debug': False, 'content': part.blob})
4545
images_list.append(image)
46-
return f'![](/api/image/{image_uuid})'
46+
return f'![](/oss/file/{image_uuid})'
4747
return None
4848
return None
4949

@@ -226,7 +226,6 @@ def get_content(self, file, save_image):
226226
doc = Document(io.BytesIO(buffer))
227227
content = self.to_md(doc, image_list, get_image_id_func())
228228
if len(image_list) > 0:
229-
content = content.replace('/api/image/', '/oss/file/')
230229
save_image(image_list)
231230
return content
232231
except BaseException as e:

apps/common/handle/impl/text/xlsx_split_handle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
def post_cell(image_dict, cell_value):
1919
image = image_dict.get(cell_value, None)
2020
if image is not None:
21-
return f'![](/api/image/{image.id})'
21+
return f'![](/oss/file/{image.id})'
2222
return cell_value.replace('\n', '<br>').replace('|', '&#124;')
2323

2424

apps/knowledge/serializers/common.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -181,20 +181,6 @@ def write_image(zip_path: str, image_list: List[str]):
181181
os.makedirs(os.path.dirname(file_path))
182182
with open(os.path.join(zip_path, file_path), 'wb') as f:
183183
f.write(file.get_bytes())
184-
# else:
185-
# r = text.replace('(/api/image/', '').replace(')', '')
186-
# r = r.strip().split(" ")[0]
187-
# if not is_valid_uuid(r):
188-
# break
189-
# image_model = QuerySet(Image).filter(id=r).first()
190-
# if image_model is None:
191-
# break
192-
# zip_inner_path = os.path.join('api', 'image', r)
193-
# file_path = os.path.join(zip_path, zip_inner_path)
194-
# if not os.path.exists(os.path.dirname(file_path)):
195-
# os.makedirs(os.path.dirname(file_path))
196-
# with open(file_path, 'wb') as f:
197-
# f.write(image_model.image)
198184

199185

200186
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
223209
return problem, document_id, paragraph_id
224210

225211

226-
227212
def get_knowledge_operation_object(knowledge_id: str):
228213
knowledge_model = QuerySet(model=Knowledge).filter(id=knowledge_id).first()
229214
if knowledge_model is not None:

0 commit comments

Comments
 (0)