MediaWiki  1.34.0
UploadFromChunks Class Reference

Implements uploading from chunks. More...

Inheritance diagram for UploadFromChunks:
Collaboration diagram for UploadFromChunks:

Public Member Functions

 __construct (User $user, $stash=false, $repo=false)
 @noinspection PhpMissingParentConstructorInspection More...
 
 addChunk ( $chunkPath, $chunkSize, $offset)
 Add a chunk to the temporary directory. More...
 
 concatenateChunks ()
 Append the final chunk and ready file for parent::performUpload() More...
 
 continueChunks ( $name, $key, $webRequestUpload)
 Continue chunk uploading. More...
 
 getOffset ()
 Get the offset at which the next uploaded chunk will be appended to. More...
 
 getVirtualChunkLocation ( $index)
 Returns the virtual chunk location: More...
 
 stashFile (User $user=null)
 
 tryStashFile (User $user, $isPartial=false)
 
- Public Member Functions inherited from UploadFromFile
 getSourceType ()
 
 initialize ( $name, $webRequestUpload)
 Initialize from a filename and a WebRequestUpload. More...
 
 initializeFromRequest (&$request)
 
 verifyUpload ()
 

Public Attributes

UploadStash $stash
 
User $user
 

Protected Member Functions

 doStashFile (User $user=null)
 Calls the parent doStashFile and updates the uploadsession table to handle "chunks". More...
 

Protected Attributes

 $mChunkIndex
 
 $mFileKey
 
 $mOffset
 
 $mVirtualTempPath
 
- Protected Attributes inherited from UploadFromFile
WebRequestUpload $mUpload = null
 

Private Member Functions

 getChunkFileKey ( $index=null)
 
 getChunkIndex ()
 Get the current Chunk index. More...
 
 getChunkStatus ()
 Get the chunk db state and populate update relevant local values. More...
 
 outputChunk ( $chunkPath)
 Output the chunk to disk. More...
 
 updateChunkStatus ()
 Update the chunk db table with the current status: More...
 
 verifyChunk ()
 Verify that the chunk isn't really an evil html file. More...
 

Private Attributes

LocalRepo $repo
 

Additional Inherited Members

- Static Public Member Functions inherited from UploadFromFile
static isValidRequest ( $request)
 

Detailed Description

Implements uploading from chunks.

Author
Michael Dale

Definition at line 33 of file UploadFromChunks.php.

Constructor & Destructor Documentation

◆ __construct()

UploadFromChunks::__construct ( User  $user,
  $stash = false,
  $repo = false 
)

@noinspection PhpMissingParentConstructorInspection

Setup local pointers to stash, repo and user (similar to UploadFromStash)

Parameters
User$user
UploadStash | bool$stashDefault: false
FileRepo | bool$repoDefault: false

Definition at line 55 of file UploadFromChunks.php.

References $repo, $stash, $user, User\getId(), RepoGroup\singleton(), and wfDebug().

Member Function Documentation

◆ addChunk()

UploadFromChunks::addChunk (   $chunkPath,
  $chunkSize,
  $offset 
)

Add a chunk to the temporary directory.

Parameters
string$chunkPathPath to temporary chunk file
int$chunkSizeSize of the current chunk
int$offsetOffset of current chunk ( mutch match database chunk offset )
Returns
Status

Definition at line 238 of file UploadFromChunks.php.

References $status, getOffset(), MWException\msg(), StatusValue\newFatal(), outputChunk(), updateChunkStatus(), and verifyChunk().

◆ concatenateChunks()

UploadFromChunks::concatenateChunks ( )

Append the final chunk and ready file for parent::performUpload()

Returns
Status

Definition at line 148 of file UploadFromChunks.php.

References $ext, $status, FileRepo\DELETE_SOURCE, FileBackend\extensionFromPath(), getChunkIndex(), getOffset(), getVirtualChunkLocation(), UploadFromFile\verifyUpload(), wfDebug(), and wfDebugLog().

◆ continueChunks()

UploadFromChunks::continueChunks (   $name,
  $key,
  $webRequestUpload 
)

Continue chunk uploading.

Parameters
string$name
string$key
WebRequestUpload$webRequestUpload

Definition at line 130 of file UploadFromChunks.php.

References getChunkStatus().

◆ doStashFile()

UploadFromChunks::doStashFile ( User  $user = null)
protected

Calls the parent doStashFile and updates the uploadsession table to handle "chunks".

Parameters
User | null$user
Returns
UploadStashFile Stashed file

Definition at line 103 of file UploadFromChunks.php.

References $user, outputChunk(), and updateChunkStatus().

◆ getChunkFileKey()

UploadFromChunks::getChunkFileKey (   $index = null)
private

Definition at line 376 of file UploadFromChunks.php.

References getChunkIndex().

Referenced by getVirtualChunkLocation(), and outputChunk().

◆ getChunkIndex()

UploadFromChunks::getChunkIndex ( )
private

Get the current Chunk index.

Returns
int Index of the current chunk

Definition at line 322 of file UploadFromChunks.php.

References $mChunkIndex.

Referenced by concatenateChunks(), getChunkFileKey(), and updateChunkStatus().

◆ getChunkStatus()

UploadFromChunks::getChunkStatus ( )
private

Get the chunk db state and populate update relevant local values.

Definition at line 296 of file UploadFromChunks.php.

Referenced by continueChunks().

◆ getOffset()

UploadFromChunks::getOffset ( )

Get the offset at which the next uploaded chunk will be appended to.

Returns
int Current byte offset of the chunk file set

Definition at line 334 of file UploadFromChunks.php.

References $mOffset.

Referenced by addChunk(), concatenateChunks(), and updateChunkStatus().

◆ getVirtualChunkLocation()

UploadFromChunks::getVirtualChunkLocation (   $index)

Returns the virtual chunk location:

Parameters
int$index
Returns
string

Definition at line 221 of file UploadFromChunks.php.

References getChunkFileKey().

Referenced by concatenateChunks().

◆ outputChunk()

UploadFromChunks::outputChunk (   $chunkPath)
private

Output the chunk to disk.

Parameters
string$chunkPath
Exceptions
UploadChunkFileException
Returns
Status

Definition at line 349 of file UploadFromChunks.php.

References getChunkFileKey().

Referenced by addChunk(), and doStashFile().

◆ stashFile()

UploadFromChunks::stashFile ( User  $user = null)

Exceptions
UploadChunkVerificationException
Deprecated:
since 1.28 Use tryStashFile() instead

Definition at line 90 of file UploadFromChunks.php.

References $user, verifyChunk(), and wfDeprecated().

◆ tryStashFile()

UploadFromChunks::tryStashFile ( User  $user,
  $isPartial = false 
)

Definition at line 75 of file UploadFromChunks.php.

References $user, MWException\msg(), StatusValue\newFatal(), and verifyChunk().

◆ updateChunkStatus()

UploadFromChunks::updateChunkStatus ( )
private

Update the chunk db table with the current status:

Definition at line 276 of file UploadFromChunks.php.

References getChunkIndex(), getOffset(), and wfDebug().

Referenced by addChunk(), and doStashFile().

◆ verifyChunk()

UploadFromChunks::verifyChunk ( )
private

Verify that the chunk isn't really an evil html file.

Exceptions
UploadChunkVerificationException

Definition at line 389 of file UploadFromChunks.php.

References $mFileKey, and $res.

Referenced by addChunk(), stashFile(), and tryStashFile().

Member Data Documentation

◆ $mChunkIndex

UploadFromChunks::$mChunkIndex
protected

Definition at line 42 of file UploadFromChunks.php.

Referenced by getChunkIndex().

◆ $mFileKey

UploadFromChunks::$mFileKey
protected

Definition at line 43 of file UploadFromChunks.php.

Referenced by verifyChunk().

◆ $mOffset

UploadFromChunks::$mOffset
protected

Definition at line 41 of file UploadFromChunks.php.

Referenced by getOffset().

◆ $mVirtualTempPath

UploadFromChunks::$mVirtualTempPath
protected

Definition at line 44 of file UploadFromChunks.php.

◆ $repo

LocalRepo UploadFromChunks::$repo
private

Definition at line 35 of file UploadFromChunks.php.

Referenced by __construct().

◆ $stash

UploadStash UploadFromChunks::$stash

Definition at line 37 of file UploadFromChunks.php.

Referenced by __construct().

◆ $user

User UploadFromChunks::$user

Definition at line 39 of file UploadFromChunks.php.

Referenced by __construct(), doStashFile(), stashFile(), and tryStashFile().


The documentation for this class was generated from the following file: