28use InvalidArgumentException;
38 private const UNKNOWN_CONTENT_TYPE =
'unknown/unknown';
60 throw new InvalidArgumentException( __FUNCTION__ .
" given storage path '$fname'." );
66 'obResetFunc' =>
'wfResetOutputBuffers',
67 'streamMimeFunc' => [ __CLASS__,
'contentTypeFromPath' ]
71 return $streamer->stream( $headers, $sendErrors, $optHeaders, $flags );
85 $ext = strrchr( $filename,
'.' );
88 # trivial detection by file extension,
89 # used for thumbnails (thumb.php)
90 if ( $trivialMimeDetection ) {
101 return self::UNKNOWN_CONTENT_TYPE;
108 $type = $magic->getMimeTypeFromExtensionOrNull(
$ext );
124 return self::UNKNOWN_CONTENT_TYPE;
127 $checkFileExtensions &&
128 $strictFileExtensions &&
131 return self::UNKNOWN_CONTENT_TYPE;
133 if ( $verifyMimeType && $type !==
null && in_array( strtolower( $type ), $mimeTypeExclusions ) ) {
134 return self::UNKNOWN_CONTENT_TYPE;
144class_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.
if(!is_readable( $file)) $ext