code: def _get_file_magic_name(self, buffer):
          
          default = "Unknown"
          ftype = None
  
          try:
              # Magic is optional
              import magic
          except ImportError:
              return default
  
          try:
              # There are several implementations of magic,
              # unfortunately all called magic
              # We use this one: https://github.com/ahupp/python-magic/
              getattr(magic, "MagicException")
          except AttributeError:
              # Looks like no magic was installed
              return default
  
          try:
              ftype = magic.from_buffer(buffer[:1024])
          except magic.MagicError as e:
              log.exception("Error getting the magic type!")
              return default
  
          if not ftype:
              return default
          else:
              return self._patch_magic(buffer, ftype)
docs: Return the filetype guessed for a buffer
          :param buffer: bytes
          :return: str of filetype