mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-14 10:45:52 +08:00
deal the external image when extract docx image (#5024)
This commit is contained in:
parent
ea0219a5d5
commit
3b60c28b3a
@ -76,6 +76,18 @@ class WordExtractor(BaseExtractor):
|
||||
for rel in doc.part.rels.values():
|
||||
if "image" in rel.target_ref:
|
||||
image_count += 1
|
||||
if rel.is_external:
|
||||
url = rel.reltype
|
||||
response = requests.get(url, stream=True)
|
||||
if response.status_code == 200:
|
||||
image_ext = mimetypes.guess_extension(response.headers['Content-Type'])
|
||||
file_uuid = str(uuid.uuid4())
|
||||
file_key = 'image_files/' + self.tenant_id + '/' + file_uuid + '.' + image_ext
|
||||
mime_type, _ = mimetypes.guess_type(file_key)
|
||||
storage.save(file_key, response.content)
|
||||
else:
|
||||
continue
|
||||
else:
|
||||
image_ext = rel.target_ref.split('.')[-1]
|
||||
# user uuid as file name
|
||||
file_uuid = str(uuid.uuid4())
|
||||
|
Loading…
x
Reference in New Issue
Block a user