def getBufferMime(path, buffer): return magic.from_buffer(buffer, mime=True)
def getFileMime(file): mime = magic.from_buffer(file.read(1024), mime=True) file.close() # properly close the file return mime