MediaWiki  1.29.1
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)
 Setup local pointers to stash, repo and user (similar to UploadFromStash) 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)
 {} More...
 
 stashFileGetKey ()
 {} More...
 
 stashSession ()
 {} More...
 
 tryStashFile (User $user, $isPartial=false)
 {} More...
 
- Public Member Functions inherited from UploadFromFile
 getSourceType ()
 
 initialize ( $name, $webRequestUpload)
 Initialize from a filename and a WebRequestUpload. More...
 
 initializeFromRequest (&$request)
 
 verifyUpload ()
 

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 30 of file UploadFromChunks.php.

Constructor & Destructor Documentation

◆ __construct()

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

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 45 of file UploadFromChunks.php.

References $repo, $user, RepoGroup\singleton(), user, 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 252 of file UploadFromChunks.php.

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

◆ concatenateChunks()

UploadFromChunks::concatenateChunks ( )

◆ continueChunks()

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

Continue chunk uploading.

Parameters
string$name
string$key
WebRequestUpload$webRequestUpload

Definition at line 145 of file UploadFromChunks.php.

References $name, and 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 118 of file UploadFromChunks.php.

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

◆ getChunkFileKey()

UploadFromChunks::getChunkFileKey (   $index = null)
private

Definition at line 390 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 336 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 310 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 348 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 235 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 363 of file UploadFromChunks.php.

References captcha-old\count, and getChunkFileKey().

Referenced by addChunk(), and doStashFile().

◆ stashFile()

UploadFromChunks::stashFile ( User  $user = null)

{}

Exceptions
UploadChunkVerificationException
Deprecated:
since 1.28 Use tryStashFile() instead

Definition at line 84 of file UploadFromChunks.php.

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

◆ stashFileGetKey()

UploadFromChunks::stashFileGetKey ( )

{}

Exceptions
UploadChunkVerificationException
Deprecated:
since 1.28

Definition at line 95 of file UploadFromChunks.php.

References verifyChunk(), and wfDeprecated().

◆ stashSession()

UploadFromChunks::stashSession ( )

{}

Exceptions
UploadChunkVerificationException
Deprecated:
since 1.28

Definition at line 106 of file UploadFromChunks.php.

References verifyChunk(), and wfDeprecated().

◆ tryStashFile()

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

{}

Definition at line 69 of file UploadFromChunks.php.

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

◆ updateChunkStatus()

UploadFromChunks::updateChunkStatus ( )
private

Update the chunk db table with the current status:

Definition at line 290 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 403 of file UploadFromChunks.php.

References $mFileKey, and $res.

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

Member Data Documentation

◆ $mChunkIndex

UploadFromChunks::$mChunkIndex
protected

Definition at line 32 of file UploadFromChunks.php.

Referenced by getChunkIndex().

◆ $mFileKey

UploadFromChunks::$mFileKey
protected

Definition at line 33 of file UploadFromChunks.php.

Referenced by verifyChunk().

◆ $mOffset

UploadFromChunks::$mOffset
protected

Definition at line 31 of file UploadFromChunks.php.

Referenced by getOffset().

◆ $mVirtualTempPath

UploadFromChunks::$mVirtualTempPath
protected

Definition at line 34 of file UploadFromChunks.php.

◆ $repo

LocalRepo UploadFromChunks::$repo
private

Definition at line 36 of file UploadFromChunks.php.

Referenced by __construct().


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