mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
chore: update regex pattern and file path in common.py
--bug=1061351 --user=刘瑞斌 【知识库】知识库导出zip没有图片 https://www.tapd.cn/62980211/s/1768275
This commit is contained in:
parent
7f96e607b4
commit
b6e6815f25
|
|
@ -327,7 +327,7 @@ def flat_map(array: List[List]):
|
|||
|
||||
|
||||
def parse_image(content: str):
|
||||
matches = re.finditer("!\[.*?\]\(\/oss\/(image|file)\/.*?\)", content)
|
||||
matches = re.finditer("!\[.*?\]\(\.\/oss\/(image|file)\/.*?\)", content)
|
||||
image_list = [match.group() for match in matches]
|
||||
return image_list
|
||||
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ def write_image(zip_path: str, image_list: List[str]):
|
|||
file = QuerySet(File).filter(id=r).first()
|
||||
if file is None:
|
||||
break
|
||||
zip_inner_path = os.path.join('api', 'file', r)
|
||||
zip_inner_path = os.path.join('oss', 'file', 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))
|
||||
|
|
|
|||
|
|
@ -590,10 +590,10 @@ class DocumentSerializers(serializers.Serializer):
|
|||
|
||||
workbook = DocumentSerializers.Operate.get_workbook(data_dict, document_dict)
|
||||
response = HttpResponse(content_type='application/zip')
|
||||
response['Content-Disposition'] = 'attachment; filename="archive.zip"'
|
||||
response['Content-Disposition'] = f'attachment; filename="{document.name}.zip"'
|
||||
zip_buffer = io.BytesIO()
|
||||
with TemporaryDirectory() as tempdir:
|
||||
knowledge_file = os.path.join(tempdir, 'knowledge.xlsx')
|
||||
knowledge_file = os.path.join(tempdir, 'document.xlsx')
|
||||
workbook.save(knowledge_file)
|
||||
for r in res:
|
||||
write_image(tempdir, r)
|
||||
|
|
|
|||
Loading…
Reference in New Issue