| 1 |
<?php |
| 2 |
namespace WPIDE\App\Services\Storage\Adapters; |
| 3 |
|
| 4 |
use League\Flysystem\Adapter\Local; |
| 5 |
use League\MimeTypeDetection\ExtensionMimeTypeDetector; |
| 6 |
use League\MimeTypeDetection\FinfoMimeTypeDetector; |
| 7 |
|
| 8 |
class DefaultFileSystem extends Local |
| 9 |
{ |
| 10 |
/** |
| 11 |
* @inheritdoc |
| 12 |
*/ |
| 13 |
public function getMimetype($path) |
| 14 |
{ |
| 15 |
$location = $this->applyPathPrefix($path); |
| 16 |
if(extension_loaded('fileinfo')) { |
| 17 |
$mimeDetector = new FinfoMimeTypeDetector(); |
| 18 |
}else{ |
| 19 |
$mimeDetector = new ExtensionMimeTypeDetector(); |
| 20 |
} |
| 21 |
$mimetype = $mimeDetector->detectMimeTypeFromPath($location); |
| 22 |
|
| 23 |
return ['path' => $path, 'type' => 'file', 'mimetype' => $mimetype]; |
| 24 |
} |
| 25 |
|
| 26 |
} |