Skip to content

Commit

Permalink
api: views: replace magic to mimetypes library
Browse files Browse the repository at this point in the history
  • Loading branch information
BibianaC authored and michaelwood committed Feb 19, 2021
1 parent 378ffe6 commit 826d7b9
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions standards_lab/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@

import json
import os
import magic
import mimetypes
import shutil
import io

import processor.cove

Expand Down Expand Up @@ -41,7 +40,7 @@ class BadMimeTypeException(Exception):
def check_allowed_project_mime_type(file_path):
"""Raises an exception if the mime of file_path is not in the
settings ALLOWED_PROJECT_MIME_TYPES otherwise returns the mime type"""
mime = magic.from_file(file_path, mime=True)
mime = mimetypes.guess_type(file_path, strict=True)[0]
if mime not in settings.ALLOWED_PROJECT_MIME_TYPES:
raise BadMimeTypeException

Expand Down

0 comments on commit 826d7b9

Please sign in to comment.