52 $fname, $headers = [], $sendErrors =
true, $optHeaders = [], $flags = 0
55 throw new InvalidArgumentException( __FUNCTION__ .
" given storage path '$fname'." );
61 'obResetFunc' =>
'wfResetOutputBuffers',
62 'streamMimeFunc' => [ __CLASS__,
'contentTypeFromPath' ]
66 return $streamer->stream( $headers, $sendErrors, $optHeaders, $flags );
77 $trivialMimeDetection = MediaWikiServices::getInstance()->getMainConfig()
78 ->get( MainConfigNames::TrivialMimeDetection );
80 $ext = strrchr( $filename,
'.' );
83 # trivial detection by file extension,
84 # used for thumbnails (thumb.php)
85 if ( $trivialMimeDetection ) {
96 return 'unknown/unknown';
99 $magic = MediaWikiServices::getInstance()->getMimeAnalyzer();
103 $type = $magic->getMimeTypeFromExtensionOrNull(
$ext );
110 $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
111 $prohibitedFileExtensions = $mainConfig->get( MainConfigNames::ProhibitedFileExtensions );
112 $checkFileExtensions = $mainConfig->get( MainConfigNames::CheckFileExtensions );
113 $strictFileExtensions = $mainConfig->get( MainConfigNames::StrictFileExtensions );
114 $fileExtensions = $mainConfig->get( MainConfigNames::FileExtensions );
115 $verifyMimeType = $mainConfig->get( MainConfigNames::VerifyMimeType );
116 $mimeTypeExclusions = $mainConfig->get( MainConfigNames::MimeTypeExclusions );
117 [ , $extList ] = UploadBase::splitExtensions( $filename );
118 if ( UploadBase::checkFileExtensionList( $extList, $prohibitedFileExtensions ) ) {
119 return 'unknown/unknown';
121 if ( $checkFileExtensions && $strictFileExtensions
122 && !UploadBase::checkFileExtensionList( $extList, $fileExtensions )
124 return 'unknown/unknown';
126 if ( $verifyMimeType &&
$type !==
null && in_array( strtolower(
$type ), $mimeTypeExclusions ) ) {
127 return 'unknown/unknown';