Reduce memory consumption in MIME type detection

We only need the first dozen bytes anyway
parent 52480d09
......@@ -17,7 +17,7 @@ from .models import Album, Photo
def validate_uploaded_archive(uploaded_file):
types = ['application/gzip', 'application/zip',
'application/x-gzip']
if magic.from_buffer(uploaded_file.read(), mime=True) not in types:
if magic.from_buffer(uploaded_file.read(1024), mime=True) not in types:
raise ValidationError("Only zip and tar files are allowed.")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment