mirror of
https://github.com/jackeilles/xygt.git
synced 2024-11-08 07:52:38 +01:00
edit retrieve mime thing
This commit is contained in:
parent
41e70bf9c3
commit
359309c830
1 changed files with 3 additions and 3 deletions
|
@ -139,11 +139,11 @@ def getData(id):
|
||||||
with open(os.path.join(Config.fileDir, secure_filename(id)), "rb") as f:
|
with open(os.path.join(Config.fileDir, secure_filename(id)), "rb") as f:
|
||||||
file = f.read()
|
file = f.read()
|
||||||
|
|
||||||
# Get MIME type from file, if fails then use magic
|
# Get the mimetype from the db
|
||||||
try:
|
try:
|
||||||
mimetype = data["mimetype"]
|
mimetype = data["mimetype"]
|
||||||
except KeyError:
|
except:
|
||||||
mimetype = magic.from_buffer(file, mime=True)
|
mimetype = "text/plain" # This is the default because it seems loads of files are being given the wrong mime
|
||||||
|
|
||||||
# Return the file with the correct MIME type
|
# Return the file with the correct MIME type
|
||||||
return send_file(io.BytesIO(file), mimetype=mimetype)
|
return send_file(io.BytesIO(file), mimetype=mimetype)
|
||||||
|
|
Loading…
Reference in a new issue