23 use Wikimedia\ScopedCallback;
33 parent::__construct(
'AssembleUploadChunks',
$title,
$params );
34 $this->removeDuplicates =
true;
37 public function run() {
40 ScopedCallback::consume( $scope );
44 $user = $context->getUser();
46 if ( !$user->isRegistered() ) {
47 $this->
setLastError(
"Could not load the author user from session." );
54 $this->params[
'filekey'],
55 [
'result' =>
'Poll',
'stage' =>
'assembling',
'status' =>
Status::newGood() ]
59 $upload->continueChunks(
60 $this->params[
'filename'],
61 $this->params[
'filekey'],
66 $status = $upload->concatenateChunks();
67 if ( !$status->isGood() ) {
70 $this->params[
'filekey'],
71 [
'result' =>
'Failure',
'stage' =>
'assembling',
'status' => $status ]
84 $upload->checkWarnings( $user )
89 $newFileKey = $upload->getStashFile()->getFileKey();
92 $upload->stash->removeFileNoAuth( $this->params[
'filekey'] );
96 $imageInfo = $upload->getImageInfo( $apiMain->getResult() );
99 $upload->cleanupTempFile();
104 $this->params[
'filekey'],
106 'result' =>
'Success',
107 'stage' =>
'assembling',
108 'filekey' => $newFileKey,
109 'imageinfo' => $imageInfo,
113 }
catch ( Exception $e ) {
116 $this->params[
'filekey'],
118 'result' =>
'Failure',
119 'stage' =>
'assembling',
123 $this->
setLastError( get_class( $e ) .
": " . $e->getMessage() );
134 $info = parent::getDeduplicationInfo();
135 if ( is_array( $info[
'params'] ) ) {
136 $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 newFatal( $message,... $parameters)
Factory function for fatal errors.
static newGood( $value=null)
Factory function for good results.
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.