/** * 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. * * @param $key String: the key of a particular requested file */ public function showUpload($key) { global $wgOut; // prevent callers from doing standard HTML output -- we'll take it from here $wgOut->disable(); try { $params = $this->parseKey($key); if ($params['type'] === 'thumb') { return $this->outputThumbFromStash($params['file'], $params['params']); } else { return $this->outputLocalFile($params['file']); } } catch (UploadStashFileNotFoundException $e) { $code = 404; $message = $e->getMessage(); } catch (UploadStashZeroLengthFileException $e) { $code = 500; $message = $e->getMessage(); } catch (UploadStashBadPathException $e) { $code = 500; $message = $e->getMessage(); } catch (SpecialUploadStashTooLargeException $e) { $code = 500; $message = 'Cannot serve a file larger than ' . self::MAX_SERVE_BYTES . ' bytes. ' . $e->getMessage(); } catch (Exception $e) { $code = 500; $message = $e->getMessage(); } wfHttpError($code, OutputPage::getStatusMessage($code), $message); return false; }