34
34
*/
35
35
class HttpuploadComponent extends AppComponent
36
36
{
37
- public $ tmpDirectory = '' ;
38
37
public $ tokenParamName = 'uploadtoken ' ;
39
38
public $ testingEnable = false ;
40
39
41
- /** Set the upload temporary directory */
42
- public function setTmpDirectory ($ dir )
43
- {
44
- $ this ->tmpDirectory = $ dir ;
45
- }
46
-
47
40
/** Set whether we are in testing mode or not (boolean) */
48
41
public function setTestingMode ($ testing )
49
42
{
@@ -68,7 +61,7 @@ public function generateToken($args, $dirname = '')
68
61
throw new Exception ('Parameter filename is not defined ' , MIDAS_HTTPUPLOAD_FILENAME_PARAM_UNDEFINED );
69
62
}
70
63
$ dir = $ dirname == '' ? '' : '/ ' .$ dirname ;
71
- $ dir = $ this -> tmpDirectory .$ dir ;
64
+ $ dir = UtilityComponent:: getTempDirectory () .$ dir ;
72
65
73
66
if (!file_exists ($ dir )) {
74
67
if (!mkdir ($ dir , 0700 , true )) {
@@ -79,10 +72,10 @@ public function generateToken($args, $dirname = '')
79
72
if ($ dirname != '' ) {
80
73
$ unique_identifier = $ dirname .'/ ' .$ unique_identifier ;
81
74
}
82
- if (file_exists ($ this -> tmpDirectory .'/ ' .$ unique_identifier )) {
75
+ if (file_exists (UtilityComponent:: getTempDirectory () .'/ ' .$ unique_identifier )) {
83
76
throw new Exception ('Failed to generate upload token ' , MIDAS_HTTPUPLOAD_UPLOAD_TOKEN_GENERATION_FAILED );
84
77
}
85
- touch ($ this -> tmpDirectory .'/ ' .$ unique_identifier );
78
+ touch (UtilityComponent:: getTempDirectory () .'/ ' .$ unique_identifier );
86
79
87
80
return array ('token ' => $ unique_identifier );
88
81
}
@@ -113,7 +106,7 @@ public function process($args)
113
106
}
114
107
115
108
// check if the temporary file exists
116
- $ pathTemporaryFilename = $ this -> tmpDirectory .'/ ' .$ uploadToken ;
109
+ $ pathTemporaryFilename = UtilityComponent:: getTempDirectory () .'/ ' .$ uploadToken ;
117
110
if (!file_exists ($ pathTemporaryFilename )) {
118
111
throw new Exception (
119
112
'Invalid upload token ' .$ pathTemporaryFilename , MIDAS_HTTPUPLOAD_INVALID_UPLOAD_TOKEN
@@ -192,7 +185,7 @@ public function getOffset($args)
192
185
);
193
186
}
194
187
$ uploadToken = $ args [$ this ->tokenParamName ];
195
- $ offset = UtilityComponent::fileSize ($ this -> tmpDirectory .'/ ' .$ uploadToken );
188
+ $ offset = UtilityComponent::fileSize (UtilityComponent:: getTempDirectory () .'/ ' .$ uploadToken );
196
189
197
190
return array ('offset ' => $ offset );
198
191
}
0 commit comments