53 $this->repo = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo();
60 wfDebug( __METHOD__ .
" creating new UploadStash instance for " . $user->getId() );
62 wfDebug( __METHOD__ .
" creating new UploadStash instance with no user" );
65 $this->stash =
new UploadStash( $this->repo, $user );
86 return self::isValidKey( $request->getText(
'wpFileKey', $request->getText(
'wpSessionKey' ) ) );
94 public function initialize( $key, $name =
'upload_file', $initTempFile =
true ) {
101 $metadata = $this->stash->getMetadata( $key );
103 $initTempFile ? $this->
getRealPath( $metadata[
'us_path'] ) :
false,
104 $metadata[
'us_size'],
108 $this->mFileKey = $key;
109 $this->mVirtualTempPath = $metadata[
'us_path'];
110 $this->mFileProps = $this->stash->getFileProps( $key );
111 $this->mSourceType = $metadata[
'us_source_type'];
119 $fileKey = $request->getText(
'wpFileKey', $request->getText(
'wpSessionKey' ) );
122 $desiredDestName = $request->getText(
124 $request->getText(
'wpUploadFile', $request->getText(
'filename' ) )
127 $this->
initialize( $fileKey, $desiredDestName );
142 return $this->mFileProps[
'sha1'];
150 return $this->stash->removeFile( $this->mFileKey );
157 parent::postProcessUpload();
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
UploadBase and subclasses are the backend of MediaWiki's file uploads.
initializePathInfo( $name, $tempPath, $fileSize, $removeTempFile=false)
Implements uploading from previously stored file.
getTempFileSha1Base36()
Get the base 36 SHA1 of the file.
static isValidRequest( $request)
initializeFromRequest(&$request)
unsaveUploadedFile()
Remove a temporarily kept file stashed by saveTempUploadedFile().
postProcessUpload()
Remove the database record after a successful upload.
__construct( $user=false, $stash=false, $repo=false)
initialize( $key, $name='upload_file', $initTempFile=true)
UploadStash is intended to accomplish a few things: