Skip to content

Commit b6e6815

Browse files
committed
chore: update regex pattern and file path in common.py
--bug=1061351 --user=刘瑞斌 【知识库】知识库导出zip没有图片 https://www.tapd.cn/62980211/s/1768275
1 parent 7f96e60 commit b6e6815

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

apps/common/utils/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ def flat_map(array: List[List]):
327327

328328

329329
def parse_image(content: str):
330-
matches = re.finditer("!\[.*?\]\(\/oss\/(image|file)\/.*?\)", content)
330+
matches = re.finditer("!\[.*?\]\(\.\/oss\/(image|file)\/.*?\)", content)
331331
image_list = [match.group() for match in matches]
332332
return image_list
333333

apps/knowledge/serializers/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def write_image(zip_path: str, image_list: List[str]):
177177
file = QuerySet(File).filter(id=r).first()
178178
if file is None:
179179
break
180-
zip_inner_path = os.path.join('api', 'file', r)
180+
zip_inner_path = os.path.join('oss', 'file', r)
181181
file_path = os.path.join(zip_path, zip_inner_path)
182182
if not os.path.exists(os.path.dirname(file_path)):
183183
os.makedirs(os.path.dirname(file_path))

apps/knowledge/serializers/document.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,10 +590,10 @@ def export_zip(self, with_valid=True):
590590

591591
workbook = DocumentSerializers.Operate.get_workbook(data_dict, document_dict)
592592
response = HttpResponse(content_type='application/zip')
593-
response['Content-Disposition'] = 'attachment; filename="archive.zip"'
593+
response['Content-Disposition'] = f'attachment; filename="{document.name}.zip"'
594594
zip_buffer = io.BytesIO()
595595
with TemporaryDirectory() as tempdir:
596-
knowledge_file = os.path.join(tempdir, 'knowledge.xlsx')
596+
knowledge_file = os.path.join(tempdir, 'document.xlsx')
597597
workbook.save(knowledge_file)
598598
for r in res:
599599
write_image(tempdir, r)

0 commit comments

Comments
 (0)