From 33fab474faf8530fa81be9165d393a9816e76d17 Mon Sep 17 00:00:00 2001 From: Jack Eilles Date: Sun, 28 Jan 2024 10:38:04 +0000 Subject: [PATCH] fixed issue with bad mimetypes, deploying. --- app/worker.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/worker.py b/app/worker.py index 42625d1..d76a521 100644 --- a/app/worker.py +++ b/app/worker.py @@ -10,7 +10,8 @@ import os def uploadFile(file, ip, userid, filename, id, retention): # Is the MIME and file size good? - if magic.from_buffer(file, mime=True) not in disallowedMimeTypes: + file_content = file.read() + if magic.from_buffer(file_content, mime=True) not in disallowedMimeTypes: if file.content_length <= Config.maxFileSize: # We're going to check whether the id variable has been filled @@ -52,7 +53,7 @@ def uploadFile(file, ip, userid, filename, id, retention): 'id': id, 'filename': filename, 'filesize': fileSize, - 'mimetype': magic.from_buffer(file, mime=True) if magic.from_buffer(file, mime=True) != None else "text/plain", + 'mimetype': magic.from_buffer(file_content, mime=True) if magic.from_buffer(file_content, mime=True) != None else "text/plain", 'retention': retention, 'userid': userid, 'ip': ip,