mirror of
https://github.com/jackeilles/xygt.git
synced 2024-11-21 22:32:39 +01:00
migrate to magic for mime detection
This commit is contained in:
parent
359309c830
commit
27fa621fd9
1 changed files with 3 additions and 3 deletions
|
@ -4,13 +4,13 @@ from app import bcrypt
|
||||||
import secrets
|
import secrets
|
||||||
import datetime
|
import datetime
|
||||||
import random
|
import random
|
||||||
import time
|
import magic
|
||||||
import os
|
import os
|
||||||
|
|
||||||
def uploadFile(file, ip, userid, filename, id, retention):
|
def uploadFile(file, ip, userid, filename, id, retention):
|
||||||
|
|
||||||
# Is the MIME and file size good?
|
# Is the MIME and file size good?
|
||||||
if file.content_type not in disallowedMimeTypes:
|
if magic.from_buffer(file, mime=True) not in disallowedMimeTypes:
|
||||||
if file.content_length <= Config.maxFileSize:
|
if file.content_length <= Config.maxFileSize:
|
||||||
# We're going to check whether the id variable has been filled
|
# We're going to check whether the id variable has been filled
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ def uploadFile(file, ip, userid, filename, id, retention):
|
||||||
'id': id,
|
'id': id,
|
||||||
'filename': filename,
|
'filename': filename,
|
||||||
'filesize': fileSize,
|
'filesize': fileSize,
|
||||||
'mimetype': file.content_type if file.content_type != None else "text/plain",
|
'mimetype': magic.from_buffer(file, mime=True) if magic.from_buffer(file, mime=True) != None else "text/plain",
|
||||||
'retention': retention,
|
'retention': retention,
|
||||||
'userid': userid,
|
'userid': userid,
|
||||||
'ip': ip,
|
'ip': ip,
|
||||||
|
|
Loading…
Reference in a new issue