3434 */
3535class HttpuploadComponent extends AppComponent
3636{
37- public $ tmpDirectory = '' ;
3837 public $ tokenParamName = 'uploadtoken ' ;
3938 public $ testingEnable = false ;
4039
41- /** Set the upload temporary directory */
42- public function setTmpDirectory ($ dir )
43- {
44- $ this ->tmpDirectory = $ dir ;
45- }
46-
4740 /** Set whether we are in testing mode or not (boolean) */
4841 public function setTestingMode ($ testing )
4942 {
@@ -68,7 +61,7 @@ public function generateToken($args, $dirname = '')
6861 throw new Exception ('Parameter filename is not defined ' , MIDAS_HTTPUPLOAD_FILENAME_PARAM_UNDEFINED );
6962 }
7063 $ dir = $ dirname == '' ? '' : '/ ' .$ dirname ;
71- $ dir = $ this -> tmpDirectory .$ dir ;
64+ $ dir = UtilityComponent:: getTempDirectory () .$ dir ;
7265
7366 if (!file_exists ($ dir )) {
7467 if (!mkdir ($ dir , 0700 , true )) {
@@ -79,10 +72,10 @@ public function generateToken($args, $dirname = '')
7972 if ($ dirname != '' ) {
8073 $ unique_identifier = $ dirname .'/ ' .$ unique_identifier ;
8174 }
82- if (file_exists ($ this -> tmpDirectory .'/ ' .$ unique_identifier )) {
75+ if (file_exists (UtilityComponent:: getTempDirectory () .'/ ' .$ unique_identifier )) {
8376 throw new Exception ('Failed to generate upload token ' , MIDAS_HTTPUPLOAD_UPLOAD_TOKEN_GENERATION_FAILED );
8477 }
85- touch ($ this -> tmpDirectory .'/ ' .$ unique_identifier );
78+ touch (UtilityComponent:: getTempDirectory () .'/ ' .$ unique_identifier );
8679
8780 return array ('token ' => $ unique_identifier );
8881 }
@@ -113,7 +106,7 @@ public function process($args)
113106 }
114107
115108 // check if the temporary file exists
116- $ pathTemporaryFilename = $ this -> tmpDirectory .'/ ' .$ uploadToken ;
109+ $ pathTemporaryFilename = UtilityComponent:: getTempDirectory () .'/ ' .$ uploadToken ;
117110 if (!file_exists ($ pathTemporaryFilename )) {
118111 throw new Exception (
119112 'Invalid upload token ' .$ pathTemporaryFilename , MIDAS_HTTPUPLOAD_INVALID_UPLOAD_TOKEN
@@ -192,7 +185,7 @@ public function getOffset($args)
192185 );
193186 }
194187 $ uploadToken = $ args [$ this ->tokenParamName ];
195- $ offset = UtilityComponent::fileSize ($ this -> tmpDirectory .'/ ' .$ uploadToken );
188+ $ offset = UtilityComponent::fileSize (UtilityComponent:: getTempDirectory () .'/ ' .$ uploadToken );
196189
197190 return array ('offset ' => $ offset );
198191 }
0 commit comments