// Initialize $this->mUpload
if ( $this->mParams['enablechunks'] ) {
$this->mUpload = new UploadFromChunks();
- $this->mUpload->initialize( $request );
+ $this->mUpload->initialize
+ ( $request->getText( 'done' ),
+ $request->getText( 'filename' ),
+ $request->getText( 'chunksessionkey' ),
+ $request->getFileTempName( 'chunk' ),
+ $request->getFileSize( 'chunk' ),
+ $request->getSessionData( 'wsUploadData' ) );
if ( !$this->mUpload->status->isOK() ) {
return $this->dieUsageMsg( $this->mUpload->status->getWikiText(),
'watch' => false,
'ignorewarnings' => false,
'file' => null,
- 'enablechunks' => null,
+ 'enablechunks' => false,
'chunksessionkey' => null,
'chunk' => null,
'done' => false,
'ignorewarnings' => 'Ignore any warnings',
'file' => 'File contents',
'enablechunks' => 'Set to use chunk mode; see http://firefogg.org/dev/chunk_post.html for protocol',
+ 'chunksessionkey' => 'The session key, established on the first contact during the chunked upload',
+ 'chunk' => 'The data in this chunk of a chunked upload',
+ 'done' => 'Set to 1 on the last chunk of a chunked upload',
'url' => 'Url to fetch the file from',
'sessionkey' => array(
'Session key returned by a previous upload that failed due to warnings',
throw new MWException( 'not implemented' );
}
- public function initialize( &$request ) {
- $done = $request->getText( 'done' );
- $filename = $request->getText( 'filename' );
- $sessionKey = $request->getText( 'chunksessionkey' );
-
- $this->initFromSessionKey( $sessionKey, $request );
+ public function initialize( $done, $filename, $sessionKey, $path,
+ $fileSize, $sessionData ) {
+ $this->initFromSessionKey( $sessionKey, $sessionData );
if ( !$this->sessionKey && !$done ) {
// session key not set, init the chunk upload system:
}
if ( $this->chunkMode == self::CHUNK || $this->chunkMode == self::DONE ) {
- $this->mTempPath = $request->getFileTempName( 'chunk' );
- $this->fileSize += $request->getFileSize( 'chunk' );
+ $this->mTempPath = $path;
+ $this->fileSize += $fileSize;
}
}
*
* @returns void
*/
- protected function initFromSessionKey( $sessionKey, $request ) {
+ protected function initFromSessionKey( $sessionKey, $sessionData ) {
if ( !$sessionKey || empty( $sessionKey ) ) {
$this->status = Status::newFromFatal( 'Missing session data.' );
return;
}
$this->sessionKey = $sessionKey;
- // load the sessionData array:
- $sessionData = $request->getSessionData( 'wsUploadData' );
if ( isset( $sessionData[$this->sessionKey]['version'] )
&& $sessionData[$this->sessionKey]['version'] == self::SESSION_VERSION ) {
*/
public function performUpload( $comment, $pageText, $watch, $user ) {
wfDebug( "\n\n\performUpload(chunked): sum:" . $comment . ' c: ' . $pageText . ' w:' . $watch );
- global $wgUser;
+ global $wgUser, $wgOut;
if ( $this->chunkMode == self::INIT ) {
// firefogg expects a specific result per:
'uploadUrl' => wfExpandUrl( wfScript( 'api' ) ) . "?action=upload&" .
"token={$token}&format=json&enablechunks=true&chunksessionkey=" .
$this->setupChunkSession( $comment, $pageText, $watch ) ) );
- exit( 0 );
+ $wgOut->disable();
} else if ( $this->chunkMode == self::CHUNK ) {
$status = $this->appendChunk();
if ( !$status->isOK() ) {
echo FormatJson::encode(
array( 'result' => 1, 'filesize' => $this->fileSize )
);
- exit( 0 );
+ $wgOut->disable();
} else if ( $this->chunkMode == self::DONE ) {
if ( $comment == '' )
$comment = $this->comment;
'done' => 1,
'resultUrl' => $file->getDescriptionUrl() )
);
- exit( 0 );
+ $wgOut->disable();
}
}