/** * Find the mime type of the given stream * * @param FilesystemStreamInterface $stream * @return string The mime type or NULL, if none could be guessed */ public function fromStream(FilesystemStreamInterface $stream) { $mimetype = null; if (static::isSupported()) { if ($path = $stream->getPath()) { $mimetype = $this->_getMimetype(strtolower(pathinfo($path, PATHINFO_EXTENSION))); } } return $mimetype; }
/** * Find the mime type of the given stream * * @param FilesystemStreamInterface $stream * @return string The mime type or NULL, if none could be guessed */ public function fromStream(FilesystemStreamInterface $stream) { $mimetype = null; if (static::isSupported()) { if ($finfo = new \finfo(FILEINFO_MIME_TYPE, $this->getConfig()->magic_file)) { if ($path = $stream->getPath()) { $mimetype = $finfo->file($path); } else { $mimetype = $finfo->buffer($stream->toString()); } } } return $mimetype; }