From 359309c830195e3faa87625514b8f9bf9675b3f6 Mon Sep 17 00:00:00 2001 From: Jack Eilles Date: Sun, 28 Jan 2024 10:24:13 +0000 Subject: [PATCH] edit retrieve mime thing --- app/routes.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/routes.py b/app/routes.py index d5f322e..3984f84 100644 --- a/app/routes.py +++ b/app/routes.py @@ -139,11 +139,11 @@ def getData(id): with open(os.path.join(Config.fileDir, secure_filename(id)), "rb") as f: file = f.read() - # Get MIME type from file, if fails then use magic + # Get the mimetype from the db try: mimetype = data["mimetype"] - except KeyError: - mimetype = magic.from_buffer(file, mime=True) + except: + 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 send_file(io.BytesIO(file), mimetype=mimetype)