MediaWiki  REL1_22
StreamFile Class Reference

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

List of all members.

Static Public Member Functions

static contentTypeFromPath ($filename, $safe=true)
 Determine the file type of a file based on the path.
static prepareForStream ($path, $info, $headers=array(), $sendErrors=true)
 Call this function used in preparation before streaming a file.
static stream ($fname, $headers=array(), $sendErrors=true)
 Stream a file to the browser, adding all the headings and fun stuff.

Public Attributes

const NOT_MODIFIED = 2
const READY_STREAM = 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 151 of file StreamFile.php.

References $ext, $wgFileExtensions, $wgTrivialMimeDetection, UploadBase\checkFileExtensionList(), global, list, MimeMagic\singleton(), and UploadBase\splitExtensions().

Referenced by prepareForStream().

static StreamFile::prepareForStream ( path,
info,
headers = array(),
sendErrors = true 
) [static]

Call this function used in preparation before streaming a file.

This function does the following: (a) sends Last-Modified, Content-type, and Content-Disposition headers (b) cancels any PHP output buffering and automatic gzipping of output (c) sends Content-Length header based on HTTP_IF_MODIFIED_SINCE check

Parameters:
string$pathStorage path or file system path
array | bool$infoFile stat info with 'mtime' and 'size' fields
array$headersAdditional headers to send
bool$sendErrorsSend error messages if errors occur (like 404)
Returns:
int|bool READY_STREAM, NOT_MODIFIED, or false on failure

Definition at line 81 of file StreamFile.php.

References $path, as, contentTypeFromPath(), empty, NOT_MODIFIED, READY_STREAM, wfResetOutputBuffers(), and wfTimestamp().

Referenced by stream().

static StreamFile::stream ( fname,
headers = array(),
sendErrors = true 
) [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
bool$sendErrorsSend error messages if errors occur (like 404)
Exceptions:
MWException
Returns:
bool Success

Definition at line 41 of file StreamFile.php.

References $fname, $ok, $res, FileBackend\isStoragePath(), prepareForStream(), wfProfileIn(), wfProfileOut(), wfRestoreWarnings(), and wfSuppressWarnings().

Referenced by wfStreamFile().


Member Data Documentation

Definition at line 28 of file StreamFile.php.

Referenced by prepareForStream().

Definition at line 27 of file StreamFile.php.

Referenced by prepareForStream().


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