MediaWiki  master
StreamFile Class Reference

Functions related to the output of file content. More...

Static Public Member Functions

static contentTypeFromPath ($filename, $safe=true)
 Determine the file type of a file based on the path. More...
 
static parseRange ($range, $size)
 Convert a Range header value to an absolute (start, end) range tuple. More...
 
static send404Message ($fname, $flags=0)
 Send out a standard 404 message for a file. More...
 
static stream ($fname, $headers=[], $sendErrors=true, $optHeaders=[], $flags=0)
 Stream a file to the browser, adding all the headings and fun stuff. More...
 

Public Attributes

const STREAM_ALLOW_OB = 2
 
const STREAM_HEADLESS = 1
 

Detailed Description

Functions related to the output of file content.

Definition at line 26 of file StreamFile.php.

Member Function Documentation

static StreamFile::contentTypeFromPath (   $filename,
  $safe = true 
)
static

Determine the file type of a file based on the path.

Parameters
string$filenameStorage path or file system path
bool$safeWhether to do retroactive upload blacklist checks
Returns
null|string

Definition at line 224 of file StreamFile.php.

References $ext, $type, $wgCheckFileExtensions, $wgFileBlacklist, $wgFileExtensions, $wgMimeTypeBlacklist, $wgStrictFileExtensions, $wgTrivialMimeDetection, $wgVerifyMimeType, UploadBase\checkFileExtensionList(), global, list, MimeMagic\singleton(), and UploadBase\splitExtensions().

Referenced by FileBackendDBRepoWrapper\streamFile().

static StreamFile::parseRange (   $range,
  $size 
)
static

Convert a Range header value to an absolute (start, end) range tuple.

Parameters
string$rangeRange header value
integer$sizeFile size
Returns
array|string Returns error string on failure (start, end, length)
Since
1.24

Definition at line 190 of file StreamFile.php.

References list.

static StreamFile::send404Message (   $fname,
  $flags = 0 
)
static

Send out a standard 404 message for a file.

Parameters
string$fnameFull name and path of the file to stream
integer$flagsBitfield of STREAM_* constants
Since
1.24

Definition at line 166 of file StreamFile.php.

References $flags, $fname, and HttpStatus\header().

Referenced by FileBackendStore\doStreamFile(), and SwiftFileBackend\doStreamFile().

static StreamFile::stream (   $fname,
  $headers = [],
  $sendErrors = true,
  $optHeaders = [],
  $flags = 0 
)
static

Stream a file to the browser, adding all the headings and fun stuff.

Headers sent include: Content-type, Content-Length, Last-Modified, and Content-Disposition.

Parameters
string$fnameFull name and path of the file to stream
array$headersAny additional headers to send if the file exists
bool$sendErrorsSend error messages if errors occur (like 404)
array$optHeadersHTTP request header map (e.g. "range") (use lowercase keys)
integer$flagsBitfield of STREAM_* constants
Exceptions
MWException
Returns
bool Success

Definition at line 45 of file StreamFile.php.

References $flags, $fname, $section, $type, as, false, HttpStatus\header(), FileBackend\isStoragePath(), print, TS_RFC2822, TS_UNIX, wfResetOutputBuffers(), and wfTimestamp().

Referenced by FileBackendStore\doStreamFile(), and MediaTransformOutput\streamFileWithStatus().

Member Data Documentation

const StreamFile::STREAM_ALLOW_OB = 2

Definition at line 30 of file StreamFile.php.

Referenced by FileBackendStore\doStreamFile().

const StreamFile::STREAM_HEADLESS = 1

Definition at line 28 of file StreamFile.php.

Referenced by FileBackendStore\doStreamFile(), and SwiftFileBackend\doStreamFile().


The documentation for this class was generated from the following file: