mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-12 19:49:02 +08:00
fix file encoding detection bug (#653)
### What problem does this PR solve? #651 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
parent
ca5acc151a
commit
c6b6c748ae
@ -335,7 +335,7 @@ def get(file_id):
|
|||||||
response = flask.make_response(MINIO.get(file.parent_id, file.location))
|
response = flask.make_response(MINIO.get(file.parent_id, file.location))
|
||||||
ext = re.search(r"\.([^.]+)$", file.name)
|
ext = re.search(r"\.([^.]+)$", file.name)
|
||||||
if ext:
|
if ext:
|
||||||
if doc.type == FileType.VISUAL.value:
|
if file.type == FileType.VISUAL.value:
|
||||||
response.headers.set('Content-Type', 'image/%s' % ext.group(1))
|
response.headers.set('Content-Type', 'image/%s' % ext.group(1))
|
||||||
else:
|
else:
|
||||||
response.headers.set(
|
response.headers.set(
|
||||||
|
@ -28,11 +28,17 @@ all_codecs = [
|
|||||||
def find_codec(blob):
|
def find_codec(blob):
|
||||||
global all_codecs
|
global all_codecs
|
||||||
for c in all_codecs:
|
for c in all_codecs:
|
||||||
|
try:
|
||||||
|
blob[:1024].decode(c)
|
||||||
|
return c
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
try:
|
try:
|
||||||
blob.decode(c)
|
blob.decode(c)
|
||||||
return c
|
return c
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return "utf-8"
|
return "utf-8"
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user