MediaWiki
REL1_22
|
Web access for files temporarily stored by UploadStash. More...
Public Member Functions | |
__construct () | |
execute ($subPage) | |
Execute page -- can output a file directly or show a listing of them. | |
showUpload ($key) | |
If file available in stash, cats it out to the client as a simple HTTP response. | |
Static Public Member Functions | |
static | tryClearStashedUploads ($formData) |
Static callback for the HTMLForm in showUploads, to process Note the stash has to be recreated since this is being called in a static context. | |
Public Attributes | |
const | MAX_SERVE_BYTES = 1048576 |
Private Member Functions | |
outputContents ($content, $contentType) | |
Output HTTP response of raw content Side effect: writes HTTP response to STDOUT. | |
outputLocalFile (File $file) | |
Output HTTP response for file Side effect: writes HTTP response to STDOUT. | |
outputLocallyScaledThumb ($file, $params, $flags) | |
Scale a file (probably with a locally installed imagemagick, or similar) and output it to STDOUT. | |
outputRemoteScaledThumb ($file, $params, $flags) | |
Scale a file with a remote "scaler", as exists on the Wikimedia Foundation cluster, and output it to STDOUT. | |
outputThumbFromStash ($file, $params) | |
Get a thumbnail for file, either generated locally or remotely, and stream it out. | |
parseKey ($key) | |
Parse the key passed to the SpecialPage. | |
showUploads () | |
Default action when we don't have a subpage -- just show links to the uploads we have, Also show a button to clear stashed files. | |
Static Private Member Functions | |
static | outputFileHeaders ($contentType, $size) |
Output headers for streaming XXX unsure about encoding as binary; if we received from HTTP perhaps we should use that encoding, concatted with semicolon to mimeType as it usually is. | |
Private Attributes | |
$stash |
Web access for files temporarily stored by UploadStash.
For example -- files that were uploaded with the UploadWizard extension are stored temporarily before committing them to the db. But we want to see their thumbnails and get other information about them.
Since this is based on the user's session, in effect this creates a private temporary file area. However, the URLs for the files cannot be shared.
Definition at line 35 of file SpecialUploadStash.php.
Definition at line 49 of file SpecialUploadStash.php.
References RepoGroup\singleton().
SpecialUploadStash::execute | ( | $ | subPage | ) |
Execute page -- can output a file directly or show a listing of them.
string | $subPage | subpage, e.g. in http://example.com/wiki/Special:UploadStash/foo.jpg, the "foo.jpg" part |
Reimplemented from SpecialPage.
Definition at line 63 of file SpecialUploadStash.php.
References SpecialPage\checkPermissions(), showUpload(), and showUploads().
SpecialUploadStash::outputContents | ( | $ | content, |
$ | contentType | ||
) | [private] |
Output HTTP response of raw content Side effect: writes HTTP response to STDOUT.
string | $content | content |
string | $contentType | mime type |
SpecialUploadStashTooLargeException |
Definition at line 290 of file SpecialUploadStash.php.
References $size, outputFileHeaders(), and print.
Referenced by outputRemoteScaledThumb().
static SpecialUploadStash::outputFileHeaders | ( | $ | contentType, |
$ | size | ||
) | [static, private] |
Output headers for streaming XXX unsure about encoding as binary; if we received from HTTP perhaps we should use that encoding, concatted with semicolon to mimeType as it usually is.
Side effect: preps PHP to write headers to STDOUT.
string | $contentType | : string suitable for content-type header |
string | $size,: | length in bytes |
Definition at line 307 of file SpecialUploadStash.php.
Referenced by outputContents().
SpecialUploadStash::outputLocalFile | ( | File $ | file | ) | [private] |
Output HTTP response for file Side effect: writes HTTP response to STDOUT.
$file | File object with a local path (e.g. UnregisteredLocalFile, LocalFile. Oddly these don't share an ancestor!) |
SpecialUploadStashTooLargeException |
Definition at line 272 of file SpecialUploadStash.php.
References array(), File\getPath(), File\getRepo(), File\getSize(), and MAX_SERVE_BYTES.
Referenced by outputLocallyScaledThumb(), and showUpload().
SpecialUploadStash::outputLocallyScaledThumb | ( | $ | file, |
$ | params, | ||
$ | flags | ||
) | [private] |
Scale a file (probably with a locally installed imagemagick, or similar) and output it to STDOUT.
$file | File | |
array | $params | Scaling parameters ( e.g. array( width => '50' ) ); |
int | $flags | Scaling flags ( see File:: constants ) |
MWException | |
UploadStashFileNotFoundException |
Definition at line 181 of file SpecialUploadStash.php.
References $file, $flags, $params, false, outputLocalFile(), and File\RENDER_NOW.
Referenced by outputThumbFromStash().
SpecialUploadStash::outputRemoteScaledThumb | ( | $ | file, |
$ | params, | ||
$ | flags | ||
) | [private] |
Scale a file with a remote "scaler", as exists on the Wikimedia Foundation cluster, and output it to STDOUT.
Note: unlike the usual thumbnail process, the web client never sees the cluster URL; we do the whole HTTP transaction to the scaler ourselves and cat the results out. Note: We rely on NFS to have propagated the file contents to the scaler. However, we do not rely on the thumbnail being created in NFS and then propagated back to our filesystem. Instead we take the results of the HTTP request instead. Note: no caching is being done here, although we are instructing the client to cache it forever.
$file,: | File object |
$params,: | scaling parameters ( e.g. array( width => '50' ) ); |
$flags,: | scaling flags ( see File:: constants ) |
MWException |
Definition at line 223 of file SpecialUploadStash.php.
References $file, $params, array(), MWHttpRequest\factory(), global, outputContents(), and wfExpandUrl().
Referenced by outputThumbFromStash().
SpecialUploadStash::outputThumbFromStash | ( | $ | file, |
$ | params | ||
) | [private] |
Get a thumbnail for file, either generated locally or remotely, and stream it out.
$file | |
$params | array |
Definition at line 157 of file SpecialUploadStash.php.
References $file, $flags, $params, global, outputLocallyScaledThumb(), and outputRemoteScaledThumb().
Referenced by showUpload().
SpecialUploadStash::parseKey | ( | $ | key | ) | [private] |
Parse the key passed to the SpecialPage.
Returns an array containing the associated file object, the type ('file' or 'thumb') and if application the transform parameters
string | $key |
UploadStashBadPathException |
Definition at line 120 of file SpecialUploadStash.php.
References $file, $key, $params, and array().
Referenced by showUpload().
SpecialUploadStash::showUpload | ( | $ | key | ) |
If file available in stash, cats it out to the client as a simple HTTP response.
n.b. Most sanity checking done in UploadStashLocalFile, so this is straightforward.
string | $key | the key of a particular requested file |
HttpError |
Definition at line 80 of file SpecialUploadStash.php.
References $key, $params, SpecialPage\getOutput(), outputLocalFile(), outputThumbFromStash(), and parseKey().
Referenced by execute().
SpecialUploadStash::showUploads | ( | ) | [private] |
Default action when we don't have a subpage -- just show links to the uploads we have, Also show a button to clear stashed files.
Definition at line 340 of file SpecialUploadStash.php.
References $file, $files, $form, array(), as, Html\element(), SpecialPage\getContext(), SpecialPage\getOutput(), SpecialPage\getTitle(), SpecialPage\msg(), SpecialPage\outputHeader(), Html\rawElement(), SpecialPage\setHeaders(), and text.
Referenced by execute().
static SpecialUploadStash::tryClearStashedUploads | ( | $ | formData | ) | [static] |
Static callback for the HTMLForm in showUploads, to process Note the stash has to be recreated since this is being called in a static context.
This works, because there really is only one stash per logged-in user, despite appearances.
array | $formData |
Definition at line 324 of file SpecialUploadStash.php.
References $stash, Status\newFatal(), Status\newGood(), RepoGroup\singleton(), true, and wfDebug().
SpecialUploadStash::$stash [private] |
Definition at line 37 of file SpecialUploadStash.php.
Referenced by tryClearStashedUploads().
const SpecialUploadStash::MAX_SERVE_BYTES = 1048576 |
Definition at line 47 of file SpecialUploadStash.php.
Referenced by outputLocalFile().