Guest User

Untitled

a guest
Jan 20th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. mime = magic.Magic(mime=True)
  2. content_type = mime.from_buffer((data).read(1024))
  3. request.session['content_type'] = content_type
  4. if content_type == 'application/pdf' or content_type == 'application/msword':
  5. request.session['upload_status'] = "Content type is valid according to (MAGIC)"
  6.  
  7. import magic
  8. magic.from_buffer(open("testdata/test.pdf").read(1024))
Add Comment
Please, Sign In to add comment