TYPO3  7.6
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Download Class Reference
Inheritance diagram for 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 (   $directory,
  $filename = '' 
)

Constructor

Exceptions
\InvalidArgumentExceptionif directory is not found or is not within the PATH_site
Parameters
string$directoryThe absolute path to the directory in which the file is saved.
string$filenameThe filename - if not set, it is determined automatically.

Definition at line 53 of file Download.php.

References $filename, Download\setDirectory(), and Download\setFilename().

Member Function Documentation

closeFile ( )
protected

Closes the file handler and fixes permissions.

Returns
void

Definition at line 168 of file Download.php.

Referenced by Download\update().

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 $filename, HTTP_Request2_Response\getHeader(), HTTP_Request2\getUrl(), and Download\setFilename().

Referenced by Download\update().

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
\UnexpectedValueExceptionif $this->filename is not set
\TYPO3\CMS\Core\Exceptionif file can not be opened
Returns
void

Definition at line 151 of file Download.php.

References Download\$targetFilename.

Referenced by Download\update().

setDirectory (   $directory)

Sets the directory and checks whether the directory is available.

Exceptions
\InvalidArgumentExceptionif directory is not found or is not within the PATH_site
Parameters
string$directoryThe absolute path to the directory in which the file is saved.
Returns
void

Definition at line 97 of file Download.php.

References GeneralUtility\isAllowedAbsPath().

Referenced by Download\__construct().

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.

References $filename.

Referenced by Download\__construct(), and Download\determineFilename().

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
\TYPO3\CMS\Core\Exceptionif file can not be opened
\UnexpectedValueExceptionif the file name is empty and can not be determined from headers
Parameters
\SplSubject | \HTTP_Request2$request
Returns
void

Definition at line 68 of file Download.php.

References Download\closeFile(), Download\determineFilename(), and Download\openFile().

Member Data Documentation

$filePointer = false
protected

Definition at line 29 of file Download.php.

$targetDirectory = ''
protected

Definition at line 39 of file Download.php.

$targetFilename = ''
protected

Definition at line 44 of file Download.php.

Referenced by Download\openFile().

$targetFilePath = ''
protected

Definition at line 34 of file Download.php.