24 use Wikimedia\ScopedCallback;
34 parent::__construct(
'AssembleUploadChunks',
$title,
$params );
35 $this->removeDuplicates =
true;
38 public function run() {
41 ScopedCallback::consume( $scope );
45 $user = $context->getUser();
47 if ( !$user->isRegistered() ) {
48 $this->
setLastError(
"Could not load the author user from session." );
55 $this->params[
'filekey'],
56 [
'result' =>
'Poll',
'stage' =>
'assembling',
'status' => Status::newGood() ]
60 $upload->continueChunks(
61 $this->params[
'filename'],
62 $this->params[
'filekey'],
67 $status = $upload->concatenateChunks();
68 if ( !$status->isGood() ) {
71 $this->params[
'filekey'],
72 [
'result' =>
'Failure',
'stage' =>
'assembling',
'status' => $status ]
82 $status = Status::newGood();
85 $upload->checkWarnings( $user )
90 $newFileKey = $upload->getStashFile()->getFileKey();
93 $upload->stash->removeFileNoAuth( $this->params[
'filekey'] );
97 $imageInfo = $upload->getImageInfo( $apiMain->getResult() );
100 $upload->cleanupTempFile();
105 $this->params[
'filekey'],
107 'result' =>
'Success',
108 'stage' =>
'assembling',
109 'filekey' => $newFileKey,
110 'imageinfo' => $imageInfo,
114 }
catch ( Exception $e ) {
117 $this->params[
'filekey'],
119 'result' =>
'Failure',
120 'stage' =>
'assembling',
121 'status' => Status::newFatal(
'api-error-stashfailed' )
124 $this->
setLastError( get_class( $e ) .
": " . $e->getMessage() );
135 $info = parent::getDeduplicationInfo();
136 if ( is_array( $info[
'params'] ) ) {
137 $info[
'params'] = [
'filekey' => $info[
'params'][
'filekey'] ];
This is the main API class, used for both external and internal processing.
Assemble the segments of a chunked upload.
__construct(Title $title, array $params)
allowRetries()
bool Whether this job can be retried on failure by job runners 1.21Stability: stableto override
getDeduplicationInfo()
Subclasses may need to override this to make duplication detection work.
Class to both describe a background job and handle jobs.
addTeardownCallback( $callback)
array $params
Array of job parameters.
static rollbackPrimaryChangesAndLog(Throwable $e, $catcher=self::CAUGHT_BY_OTHER)
Roll back any open database transactions and log the stack trace of the throwable.
static importScopedSession(array $params)
Import a client IP address, HTTP headers, user ID, and session ID.
static getMain()
Get the RequestContext object associated with the main request.
static makeWarningsSerializable( $warnings)
Convert the warnings array returned by checkWarnings() to something that can be serialized.
static setSessionStatus(UserIdentity $user, $statusKey, $value)
Set the current status of a chunked upload (used for polling).
Implements uploading from chunks.