获得文件Mime类型

@param string $path
@return array
@author yangyifan <yangyifanphp@gmail.com>
330161
public function getMimetype($path)
    {
        //创建一个临时文件
        $tmp_file = FileFunction::getTmpFile();

        file_put_contents($tmp_file, $this->readStream($path)['stream']);

        $mime_type = FileFunction::getFileMimeType($tmp_file);

        //删除临时文件

        FileFunction::deleteTmpFile($tmp_file);

        return ['mimetype' => $mime_type];
    }
1159492
public static function getFromFile($path)
    {
        if (!($path instanceof File))
            $path = new File($path);

        $ext = $path->getExtension();
        $path = $path->getFullPath();

        $type = new FileType($ext ?? "", "");
        if (empty($type->getMimeType()) && file_exists($path))
            $type->setMimeType(mime_content_type($path));

        return $type;
    }
378908
protected static function getFilesFromPath($path)
    {
        $files = [];
        $path = rtrim($path, '/') . DIRECTORY_SEPARATOR;

        if (false !== $items = scandir($path)) {
            foreach ($items as $item) {
                $file = $path . $item;
                if (is_file($file)) {
                    $extension = strtolower(pathinfo($file, PATHINFO_EXTENSION));
                    if (in_array($extension, [Packager::FILE_EXTENSION, Package::FILE_EXTENSION])) {
                        $files[] = $file;
                    }
                }
            }
        }

        return $files;
    }
58031
protected function getPath($path)
	{
		$paths = array();

		// If `$path` is an array
		if (is_array($path))
		{
			foreach ($path as $unverifiedPath)
			{
				$paths = array_merge($paths, $this->getPath($unverifiedPath));
			}

			return $paths;
		}

		// If `$path` is a directory
		if (is_dir($path))
		{
			$paths = glob($path . '/*.*');

			return $paths;
		}

		// If `$path` is a file
		if (file_exists($path))
		{
			$paths[] = $path;
		}

		return $paths;
	}
1178850
protected function getFiles($path)
    {
        $path = Str::finish($path, '/');

        if (file_exists($path . App::getLocale())) {
            return File::files($path . App::getLocale());
        } elseif (file_exists($path . config('app.fallback_locale'))) {
            return File::files($path . config('app.fallback_locale'));
        }

        return [];
    }
450326
public static function serialize(Path $path): array
    {
        $result = [];
        foreach ($path as $step) {
            $result[] = $step;
        }

        return $result;
    }
334108
public function lsFiles(string $path = '') : array
    {
        return array_filter(
            $this->ls($path),
            function(File $file) {
                return $file->isFile();
            }
        );
    }
1344525
public static function detect_mime_type($path) {
		$handle = finfo_open(FILEINFO_MIME);
		$mime_type = finfo_file($handle, $path);

		if (strpos($mime_type, ';')) {
			$mime_type = preg_replace('/;.*/', ' ', $mime_type);
		}

		return trim($mime_type);
	}
1316910
protected function getPathFromArray(array $path = array())
    {
        $tmp = array();

        foreach ($path as $value) {
            $tmp[] = rawurlencode($value);
        }

        return sprintf(
            '/%s/%s',
            rtrim($this->connectionUrlInfo['path'], '/'),
            str_replace('%2F', '/', implode('/', $tmp))
        );
    }
807373
public function getMetadata($path)
    {
        $object = $this->applyPathPrefix($path);

        try {
            $result = $this->client->getObjectMeta($this->bucket, $object);
        } catch (OssException $e) {
            return false;
        }

        return [
            'type'      => 'file',
            'dirname'   => Util::dirname($path),
            'path'      => $path,
            'timestamp' => strtotime($result['last-modified']),
            'mimetype'  => $result['content-type'],
            'size'      => $result['content-length'],
        ];
    }
561761
public static function getFile(string $path): string {
		$e = explode("/", rtrim($path, "/"));

		return $e[count($e) - 1];
	}
677078
public function get_content_type($path){
        if( file_exists($path) ){
            $info = finfo_open(FILEINFO_MIME);
            $type = finfo_file($info, $path) ;
            finfo_close($info);
            return $type ?: '' ;
        }else{
            return '';
        }
    }
879134
public function dumpFile($path)
    {
        $path = $this->resolve($path);

        return $this->dump($this->getFileContents($path), $path);
    }
1231676
public function mimeType($path)
    {
        if ($this->isDirectory($path) || $path == '/') {
            return LocalFilesystem::$directoryMimetype;
        }
        return $this->mimeTypes->typeOfName($path);
    }
1107025
public function mimetype($path)
	{
		$path = Util::normalizePath($path);

		return $this->adapter->mimetype($path);
	}
647592
public static function GetDirContent($path)
    {
        $files = array();
        $directory = opendir($path);

        while(($file = readdir($directory)) !== false)
        {
            $full_path = $path . "/" . $file;

            if(is_file($full_path))
            {
                $files[] = $full_path;
            }
            elseif($file != "." && $file != ".." && is_dir($full_path))
            {
                $files[] = $full_path;
                $files = array_merge($files, self::GetDirContent($full_path));
            }
        }

        closedir($directory);

        return $files;
    }
48779
protected function splitPathToSegments($path)
    {
        $path = MediaLibrary::validatePath($path, true);
        $path = explode('/', ltrim($path, '/'));

        $result = [];
        while (count($path) > 0) {
            $folder = array_pop($path);

            $result[$folder] = implode('/', $path).'/'.$folder;
            if (substr($result[$folder], 0, 1) != '/') {
                $result[$folder] = '/'.$result[$folder];
            }
        }

        return array_reverse($result, true);
    }