TYPO3 CMS  TYPO3_7-6
TYPO3\CMS\Core\Http\Observer\Download Class Reference
Inheritance diagram for TYPO3\CMS\Core\Http\Observer\Download:

Public Member Functions

 __construct ($directory, $filename='')
 
 update (\SplSubject $request)
 
 setDirectory ($directory)
 
 setFilename ($filename='')
 

Protected Member Functions

 determineFilename (\HTTP_Request2 $request, \HTTP_Request2_Response $response)
 
 openFile ()
 
 closeFile ()
 

Protected Attributes

 $filePointer = false
 
 $targetFilePath = ''
 
 $targetDirectory = ''
 
 $targetFilename = ''
 

Detailed Description

Observer to automatically save a http request chunk by chunk to a file. If the file already exists, it will be overwritten. This follows an example in HTTP_Request2 manual.

See also
http://pear.php.net/manual/en/package.http.http-request2.observers.php

Definition at line 24 of file Download.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Http\Observer\Download::__construct (   $directory,
  $filename = '' 
)

Member Function Documentation

◆ closeFile()

TYPO3\CMS\Core\Http\Observer\Download::closeFile ( )
protected

Closes the file handler and fixes permissions.

Returns
void

Definition at line 168 of file Download.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\fixPermissions().

Referenced by TYPO3\CMS\Core\Http\Observer\Download\update().

◆ determineFilename()

TYPO3\CMS\Core\Http\Observer\Download::determineFilename ( \HTTP_Request2  $request,
\HTTP_Request2_Response  $response 
)
protected

Determines the filename from either the 'content-disposition' header or from the basename of the current request.

Parameters
\HTTP_Request2$request
\HTTP_Request2_Response$response
Returns
void

Definition at line 129 of file Download.php.

References TYPO3\CMS\Core\Http\Observer\Download\setFilename().

Referenced by TYPO3\CMS\Core\Http\Observer\Download\update().

◆ openFile()

TYPO3\CMS\Core\Http\Observer\Download::openFile ( )
protected

Determines the absolute path to the file by combining the directory and filename. Afterwards tries to open the file for writing.

$this->filename must be set before calling this function.

Exceptions

Definition at line 151 of file Download.php.

References TYPO3\CMS\Core\Http\Observer\Download\$targetFilename.

Referenced by TYPO3\CMS\Core\Http\Observer\Download\update().

◆ setDirectory()

TYPO3\CMS\Core\Http\Observer\Download::setDirectory (   $directory)

Sets the directory and checks whether the directory is available.

Exceptions

Definition at line 97 of file Download.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\isAllowedAbsPath().

Referenced by TYPO3\CMS\Core\Http\Observer\Download\__construct().

◆ setFilename()

TYPO3\CMS\Core\Http\Observer\Download::setFilename (   $filename = '')

Sets the filename.

If the file already exists, it will be overridden

Parameters
string$filenameThe filename
Returns
void

Definition at line 116 of file Download.php.

Referenced by TYPO3\CMS\Core\Http\Observer\Download\__construct(), and TYPO3\CMS\Core\Http\Observer\Download\determineFilename().

◆ update()

TYPO3\CMS\Core\Http\Observer\Download::update ( \SplSubject  $request)

Saves current chunk to disk each time a body part is received. If the filename is empty, tries to determine it from received headers

Exceptions

Definition at line 68 of file Download.php.

References TYPO3\CMS\Core\Http\Observer\Download\closeFile(), TYPO3\CMS\Core\Http\Observer\Download\determineFilename(), and TYPO3\CMS\Core\Http\Observer\Download\openFile().

Member Data Documentation

◆ $filePointer

TYPO3\CMS\Core\Http\Observer\Download::$filePointer = false
protected

Definition at line 29 of file Download.php.

◆ $targetDirectory

TYPO3\CMS\Core\Http\Observer\Download::$targetDirectory = ''
protected

Definition at line 39 of file Download.php.

◆ $targetFilename

TYPO3\CMS\Core\Http\Observer\Download::$targetFilename = ''
protected

Definition at line 44 of file Download.php.

Referenced by TYPO3\CMS\Core\Http\Observer\Download\openFile().

◆ $targetFilePath

TYPO3\CMS\Core\Http\Observer\Download::$targetFilePath = ''
protected

Definition at line 34 of file Download.php.