28use InvalidArgumentException;
39 private const UNKNOWN_CONTENT_TYPE =
'unknown/unknown';
61 throw new InvalidArgumentException( __FUNCTION__ .
" given storage path '$fname'." );
67 'obResetFunc' =>
'wfResetOutputBuffers',
68 'streamMimeFunc' => [ __CLASS__,
'contentTypeFromPath' ],
69 'headerFunc' => [ __CLASS__,
'setHeader' ],
73 return $streamer->stream( $headers, $sendErrors, $optHeaders, $flags );
82 RequestContext::getMain()->getRequest()->response()->header(
$header );
99 $ext = strrchr( $filename,
'.' );
100 $ext = $ext ? strtolower( substr( $ext, 1 ) ) :
'';
102 # trivial detection by file extension,
103 # used for thumbnails (thumb.php)
104 if ( $trivialMimeDetection ) {
115 return self::UNKNOWN_CONTENT_TYPE;
122 $type = $magic->getMimeTypeFromExtensionOrNull( $ext );
138 return self::UNKNOWN_CONTENT_TYPE;
141 $checkFileExtensions &&
142 $strictFileExtensions &&
145 return self::UNKNOWN_CONTENT_TYPE;
147 if ( $verifyMimeType && $type !==
null && in_array( strtolower( $type ), $mimeTypeExclusions ) ) {
148 return self::UNKNOWN_CONTENT_TYPE;
156class_alias( StreamFile::class,
'StreamFile' );
Base class for all file backend classes (including multi-write backends).
static isStoragePath( $path)
Check if a given path is a "mwstore://" path.
Functions related to the output of file content.
A class containing constants representing the names of configuration variables.
const MimeTypeExclusions
Name constant for the MimeTypeExclusions setting, for use with Config::get()
const ProhibitedFileExtensions
Name constant for the ProhibitedFileExtensions setting, for use with Config::get()
const TrivialMimeDetection
Name constant for the TrivialMimeDetection setting, for use with Config::get()
const VerifyMimeType
Name constant for the VerifyMimeType setting, for use with Config::get()
const StrictFileExtensions
Name constant for the StrictFileExtensions setting, for use with Config::get()
const FileExtensions
Name constant for the FileExtensions setting, for use with Config::get()
const CheckFileExtensions
Name constant for the CheckFileExtensions setting, for use with Config::get()
UploadBase and subclasses are the backend of MediaWiki's file uploads.
static splitExtensions( $filename)
Split a file into a base name and all dot-delimited 'extensions' on the end.
static checkFileExtensionList( $ext, $list)
Perform case-insensitive match against a list of file extensions.