- public function performUpload( $comment, $pageText, $watch, $user ) {
- wfDebug( "\n\n\performUpload(chunked): comment:" . $comment . ' pageText: ' . $pageText . ' watch:' . $watch );
- global $wgUser, $wgOut;
-
- if ( $this->chunkMode == self::INIT ) {
- // firefogg expects a specific result per:
- // http://www.firefogg.org/dev/chunk_post.html
-
- // it's okay to return the token here because
- // a) the user must have requested the token to get here and
- // b) should only happen over POST
- // c) we need the token to validate chunks are coming from a non-xss request
- return Status::newGood(
- array( 'uploadUrl' => wfExpandUrl( wfScript( 'api' ) ) . "?" .
- wfArrayToCGI( array(
- 'action' => 'upload',
- 'token' => $wgUser->editToken(),
- 'format' => 'json',
- 'filename' => $this->mDesiredDestName,
- 'enablechunks' => 'true',
- 'chunksession' =>
- $this->setupChunkSession( $comment, $pageText, $watch ) ) ) ) );
- } else if ( $this->chunkMode == self::CHUNK ) {
- $this->setupChunkSession();
- $this->appendChunk();
- if ( !$this->status->isOK() ) {
- return $this->status;
- }
- // return success:
- // firefogg expects a specific result
- // http://www.firefogg.org/dev/chunk_post.html
- return Status::newGood(
- array( 'result' => 1, 'filesize' => $this->mFileSize )
- );
- } else if ( $this->chunkMode == self::DONE ) {
- $this->finalizeFile();
- // We ignore the passed-in parameters because these were set on the first contact.
- $status = parent::performUpload( $this->comment, $this->pageText, $this->watch, $user );
-
- if ( !$status->isGood() ) {
- return $status;
- }
- $file = $this->getLocalFile();