Kaynağa Gözat

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)
tags/v0.5.0
KevinHuSh 1 yıl önce
ebeveyn
işleme
c6b6c748ae
No account linked to committer's email address
2 değiştirilmiş dosya ile 7 ekleme ve 1 silme
  1. 1
    1
      api/apps/file_app.py
  2. 6
    0
      rag/nlp/__init__.py

+ 1
- 1
api/apps/file_app.py Dosyayı Görüntüle

@@ -335,7 +335,7 @@ def get(file_id):
response = flask.make_response(MINIO.get(file.parent_id, file.location))
ext = re.search(r"\.([^.]+)$", file.name)
if ext:
if doc.type == FileType.VISUAL.value:
if file.type == FileType.VISUAL.value:
response.headers.set('Content-Type', 'image/%s' % ext.group(1))
else:
response.headers.set(

+ 6
- 0
rag/nlp/__init__.py Dosyayı Görüntüle

@@ -28,11 +28,17 @@ all_codecs = [
def find_codec(blob):
global all_codecs
for c in all_codecs:
try:
blob[:1024].decode(c)
return c
except Exception as e:
pass
try:
blob.decode(c)
return c
except Exception as e:
pass
return "utf-8"

Loading…
İptal
Kaydet