Passed
Branch master (edefdc)
by xiaohui
04:15
created
sdk/Core/UploadClient.php 1 patch
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -37,10 +37,10 @@  discard block
 block discarded – undo
37 37
 			return $this->_errorResponse("FileNotExist", "file not exist");
38 38
 		}
39 39
 		if (empty($uploadOption)) {
40
-			$uploadOption = new UploadOption();     //如果用户没有传递UploadOption,则生成一个默认的
40
+			$uploadOption = new UploadOption(); //如果用户没有传递UploadOption,则生成一个默认的
41 41
 		}
42 42
 		if (empty($uploadOption->name)) {
43
-			$uploadOption->name = basename($filePath);        //如果用户没有设置name属性,则使用上传时的文件名
43
+			$uploadOption->name = basename($filePath); //如果用户没有设置name属性,则使用上传时的文件名
44 44
 		}
45 45
 		// UploadPolicy 和 UploadOption检查
46 46
 		list($isValid, $message) = $this->checkUploadInfo($uploadPolicy, $uploadOption);
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	{
68 68
 		$data = file_get_contents($filePath);
69 69
 		$uploadOption->setContent($data);
70
-		$url = $this->upload_host . Conf::UPLOAD_API_UPLOAD;		//普通上传的API
70
+		$url = $this->upload_host . Conf::UPLOAD_API_UPLOAD; //普通上传的API
71 71
 		return $this->_send_request('POST', $url, $uploadPolicy, $uploadOption);
72 72
 	}
73 73
 
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	protected function uploadSuperFile($filePath, UploadPolicy $uploadPolicy, UploadOption $uploadOption = null)
82 82
 	{
83
-		$fileSize = filesize($filePath);		// 文件大小
84
-		$blockSize = $uploadOption->blockSize;	// 文件分片大小
83
+		$fileSize = filesize($filePath); // 文件大小
84
+		$blockSize = $uploadOption->blockSize; // 文件分片大小
85 85
 		$blockNum = intval(ceil($fileSize / $blockSize)); // 文件分片后的块数
86 86
 		for ($i = 0; $i < $blockNum; $i++) {
87 87
 			$currentSize = $blockSize; // 当前文件块的大小
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
 			$httpRes = null;
95 95
 			if (0 == $i) {
96 96
 				// 分片初始化阶段
97
-				$url = $this->upload_host . Conf::UPLOAD_API_BLOCK_INIT;		//初始化分片上传的API
98
-				$uploadOption->optionType = UpOptionType::BLOCK_INIT_UPLOAD;	//初始化分片时的Option类型
97
+				$url = $this->upload_host . Conf::UPLOAD_API_BLOCK_INIT; //初始化分片上传的API
98
+				$uploadOption->optionType = UpOptionType::BLOCK_INIT_UPLOAD; //初始化分片时的Option类型
99 99
 				$httpRes = $this->_send_request('POST', $url, $uploadPolicy, $uploadOption);
100 100
 				$uploadId = isset($httpRes['uploadId']) ? $httpRes['uploadId'] : null; // 分片上传ID(OSS用于区分上传的id)
101 101
 				$id = isset($httpRes['id']) ? $httpRes['id'] : null; // 上传唯一ID(多媒体服务用于区分上传的id)
@@ -103,16 +103,16 @@  discard block
 block discarded – undo
103 103
 				$uploadOption->setUniqueIdId($id);
104 104
 			} else {
105 105
 				// 分片上传过程中
106
-				$url = $this->upload_host . Conf::UPLOAD_API_BLOCK_UPLOAD;		//分片上传过程中的API
107
-				$uploadOption->optionType = UpOptionType::BLOCK_RUN_UPLOAD;		//分片上传过程中的Option类型
108
-				$uploadOption->setPartNumber($i + 1);							//
106
+				$url = $this->upload_host . Conf::UPLOAD_API_BLOCK_UPLOAD; //分片上传过程中的API
107
+				$uploadOption->optionType = UpOptionType::BLOCK_RUN_UPLOAD; //分片上传过程中的Option类型
108
+				$uploadOption->setPartNumber($i + 1); //
109 109
 				$httpRes = $this->_send_request('POST', $url, $uploadPolicy, $uploadOption);
110 110
 			}
111 111
 			// 如果分片上传失败,则取消cancel分片上传任务,然后返回错误信息
112 112
 			if (!$httpRes['isSuccess']) {
113 113
 				if ($uploadOption->checkMutipartParas()) {
114
-					$url = $this->upload_host . Conf::UPLOAD_API_BLOCK_CANCEL;		//取消分片任务的API
115
-					$uploadOption->optionType = UpOptionType::BLOCK_CANCEL_UPLOAD;	//取消分片任务时的Option类型
114
+					$url = $this->upload_host . Conf::UPLOAD_API_BLOCK_CANCEL; //取消分片任务的API
115
+					$uploadOption->optionType = UpOptionType::BLOCK_CANCEL_UPLOAD; //取消分片任务时的Option类型
116 116
 					$this->_send_request('POST', $url, $uploadPolicy, $uploadOption); // 不判断取消分片任务返回的结果
117 117
 				}
118 118
 				return $httpRes;
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
 			$uploadOption->addPartNumberAndETag($httpRes['partNumber'], $httpRes['eTag']);
126 126
 		}
127 127
 		// 分片上传完成
128
-		$url = $this->upload_host . Conf::UPLOAD_API_BLOCK_COMPLETE;			//完成分片上传任务的API
129
-		$uploadOption->optionType = UpOptionType::BLOCK_COMPLETE_UPLOAD;		//完成分片上传任务时的Option类型
130
-		$uploadOption->setMd5(md5_file($filePath));							//文件Md5
128
+		$url = $this->upload_host . Conf::UPLOAD_API_BLOCK_COMPLETE; //完成分片上传任务的API
129
+		$uploadOption->optionType = UpOptionType::BLOCK_COMPLETE_UPLOAD; //完成分片上传任务时的Option类型
130
+		$uploadOption->setMd5(md5_file($filePath)); //文件Md5
131 131
 		return $this->_send_request('POST', $url, $uploadPolicy, $uploadOption);
132 132
 	}
133 133
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	public function uploadData($data, UploadPolicy $uploadPolicy, UploadOption $uploadOption = null)
144 144
 	{
145 145
 		if (empty($uploadOption)) {
146
-			$uploadOption = new UploadOption();     //如果用户没有传递UploadOption,则生成一个默认的
146
+			$uploadOption = new UploadOption(); //如果用户没有传递UploadOption,则生成一个默认的
147 147
 		}
148 148
 		// UploadPolicy 和 UploadOption检查
149 149
 		list($isValid, $message) = $this->checkUploadInfo($uploadPolicy, $uploadOption);
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 		}
158 158
 		// 文件不大于设定的分片大小(默认2M),则直接上传uploadMiniFile()
159 159
 		$uploadOption->setContent($data);
160
-		$url = $this->upload_host . Conf::UPLOAD_API_UPLOAD;		//普通上传的API
160
+		$url = $this->upload_host . Conf::UPLOAD_API_UPLOAD; //普通上传的API
161 161
 		return $this->_send_request('POST', $url, $uploadPolicy, $uploadOption);
162 162
 	}
163 163
 
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
 	 */
171 171
 	protected function uploadSuperData($data, UploadPolicy $uploadPolicy, UploadOption $uploadOption = null)
172 172
 	{
173
-		$dataSize = strlen($data);			// 文件大小
174
-		$blockSize = $uploadOption->blockSize;	// 文件分片大小
173
+		$dataSize = strlen($data); // 文件大小
174
+		$blockSize = $uploadOption->blockSize; // 文件分片大小
175 175
 		$blockNum = intval(ceil($dataSize / $blockSize)); // 文件分片后的块数
176 176
 		for ($i = 0; $i < $blockNum; $i++) {
177 177
 			$currentSize = $blockSize; // 当前文件块的大小
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
 			$httpRes = null;
185 185
 			if (0 == $i) {
186 186
 				// 分片初始化阶段
187
-				$url = $this->upload_host . Conf::UPLOAD_API_BLOCK_INIT;		//初始化分片上传的API
188
-				$uploadOption->optionType = UpOptionType::BLOCK_INIT_UPLOAD;	//初始化分片时的Option类型
187
+				$url = $this->upload_host . Conf::UPLOAD_API_BLOCK_INIT; //初始化分片上传的API
188
+				$uploadOption->optionType = UpOptionType::BLOCK_INIT_UPLOAD; //初始化分片时的Option类型
189 189
 				$httpRes = $this->_send_request('POST', $url, $uploadPolicy, $uploadOption);
190 190
 				$uploadId = isset($httpRes['uploadId']) ? $httpRes['uploadId'] : null; // 分片上传ID(OSS用于区分上传的id)
191 191
 				$id = isset($httpRes['id']) ? $httpRes['id'] : null; // 上传唯一ID(多媒体服务用于区分上传的id)
@@ -193,16 +193,16 @@  discard block
 block discarded – undo
193 193
 				$uploadOption->setUniqueIdId($id);
194 194
 			} else {
195 195
 				// 分片上传过程中
196
-				$url = $this->upload_host . Conf::UPLOAD_API_BLOCK_UPLOAD;		//分片上传过程中的API
197
-				$uploadOption->optionType = UpOptionType::BLOCK_RUN_UPLOAD;		//分片上传过程中的Option类型
198
-				$uploadOption->setPartNumber($i + 1);							//
196
+				$url = $this->upload_host . Conf::UPLOAD_API_BLOCK_UPLOAD; //分片上传过程中的API
197
+				$uploadOption->optionType = UpOptionType::BLOCK_RUN_UPLOAD; //分片上传过程中的Option类型
198
+				$uploadOption->setPartNumber($i + 1); //
199 199
 				$httpRes = $this->_send_request('POST', $url, $uploadPolicy, $uploadOption);
200 200
 			}
201 201
 			// 如果分片上传失败,则取消cancel分片上传任务,然后返回错误信息
202 202
 			if (!$httpRes['isSuccess']) {
203 203
 				if ($uploadOption->checkMutipartParas()) {
204
-					$url = $this->upload_host . Conf::UPLOAD_API_BLOCK_CANCEL;		//取消分片任务的API
205
-					$uploadOption->optionType = UpOptionType::BLOCK_CANCEL_UPLOAD;	//取消分片任务时的Option类型
204
+					$url = $this->upload_host . Conf::UPLOAD_API_BLOCK_CANCEL; //取消分片任务的API
205
+					$uploadOption->optionType = UpOptionType::BLOCK_CANCEL_UPLOAD; //取消分片任务时的Option类型
206 206
 					$this->_send_request('POST', $url, $uploadPolicy, $uploadOption); // 不判断取消分片任务返回的结果
207 207
 				}
208 208
 				return $httpRes;
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
 			$uploadOption->addPartNumberAndETag($httpRes['partNumber'], $httpRes['eTag']);
212 212
 		}
213 213
 		// 分片上传完成
214
-		$url = $this->upload_host . Conf::UPLOAD_API_BLOCK_COMPLETE;			//完成分片上传任务的API
215
-		$uploadOption->optionType = UpOptionType::BLOCK_COMPLETE_UPLOAD;		//完成分片上传任务时的Option类型
216
-		$uploadOption->setMd5(md5($data));							//文件Md5
214
+		$url = $this->upload_host . Conf::UPLOAD_API_BLOCK_COMPLETE; //完成分片上传任务的API
215
+		$uploadOption->optionType = UpOptionType::BLOCK_COMPLETE_UPLOAD; //完成分片上传任务时的Option类型
216
+		$uploadOption->setMd5(md5($data)); //文件Md5
217 217
 		return $this->_send_request('POST', $url, $uploadPolicy, $uploadOption);
218 218
 	}
219 219
 
@@ -224,17 +224,17 @@  discard block
 block discarded – undo
224 224
 	 * @param UploadOption $uploadOption 上传选项
225 225
 	 * @return array 初始化分片上传的结果
226 226
 	 */
227
-	public function multipartInit($filePath, UploadPolicy $uploadPolicy,  UploadOption $uploadOption)
227
+	public function multipartInit($filePath, UploadPolicy $uploadPolicy, UploadOption $uploadOption)
228 228
 	{
229 229
 		$encodePath = iconv('UTF-8', 'GB2312', $filePath); //中文需要转换成gb2312,file_exist等函数才能识别
230 230
 		if (!file_exists($encodePath)) {
231 231
 			return $this->_errorResponse("FileNotExist", "file not exist");
232 232
 		}
233 233
 		if (empty($uploadOption)) {
234
-			$uploadOption = new UploadOption();     //如果用户没有传递UploadOption,则生成一个默认的
234
+			$uploadOption = new UploadOption(); //如果用户没有传递UploadOption,则生成一个默认的
235 235
 		}
236 236
 		if (empty($uploadOption->name)) {
237
-			$uploadOption->name = basename($filePath);        //如果用户没有设置name属性,则使用上传时的文件名
237
+			$uploadOption->name = basename($filePath); //如果用户没有设置name属性,则使用上传时的文件名
238 238
 		}
239 239
 		$blockData = file_get_contents($encodePath, 0, null, 0, $uploadOption->blockSize);
240 240
 		return $this->multipartInitByData($blockData, $uploadPolicy, $uploadOption);
@@ -247,10 +247,10 @@  discard block
 block discarded – undo
247 247
 	 * @param UploadOption $uploadOption 上传选项
248 248
 	 * @return array 初始化分片上传的结果
249 249
 	 */
250
-	public function multipartInitByData($blockData, UploadPolicy $uploadPolicy,  UploadOption $uploadOption)
250
+	public function multipartInitByData($blockData, UploadPolicy $uploadPolicy, UploadOption $uploadOption)
251 251
 	{
252 252
 		if (empty($uploadOption)) {
253
-			$uploadOption = new UploadOption();     //如果用户没有传递UploadOption,则生成一个默认的
253
+			$uploadOption = new UploadOption(); //如果用户没有传递UploadOption,则生成一个默认的
254 254
 		}
255 255
 		// UploadPolicy 和 UploadOption检查
256 256
 		list($isValid, $message) = $this->checkUploadInfo($uploadPolicy, $uploadOption);
@@ -258,13 +258,13 @@  discard block
 block discarded – undo
258 258
 			return $this->_errorResponse("ErrorUploadInfo", "error upload policy or option:" . $message);
259 259
 		}
260 260
 		// 数据大小不等于设定的分片大小(默认2M),则无法完成初始化
261
-		$dataSize = strlen($blockData);			// 数据文件大小
261
+		$dataSize = strlen($blockData); // 数据文件大小
262 262
 		if ($dataSize != ($uploadOption->blockSize)) {
263 263
 			return $this->_errorResponse("MultipartInitError", "UploadOption's blockSize is not equal to data's size");
264 264
 		}
265 265
 		$uploadOption->setContent($blockData); // 设置待上传的文件块
266
-		$uploadOption->optionType = UpOptionType::BLOCK_INIT_UPLOAD;	//初始化分片时的Option类型
267
-		$url = $this->upload_host . Conf::UPLOAD_API_BLOCK_INIT;		//初始化分片上传的API
266
+		$uploadOption->optionType = UpOptionType::BLOCK_INIT_UPLOAD; //初始化分片时的Option类型
267
+		$url = $this->upload_host . Conf::UPLOAD_API_BLOCK_INIT; //初始化分片上传的API
268 268
 		$httpRes = $this->_send_request('POST', $url, $uploadPolicy, $uploadOption);
269 269
 		//若成功返回,则保存初始化成功的uploadId、id 以及 partNumber、eTag
270 270
 		$uploadId = isset($httpRes['uploadId']) ? $httpRes['uploadId'] : null; // 分片上传ID(OSS用于区分上传的id)
@@ -283,14 +283,14 @@  discard block
 block discarded – undo
283 283
 	 * @param UploadOption $uploadOption 上传选项
284 284
 	 * @return array 初始化分片上传的结果
285 285
 	 */
286
-	public function multipartUpload($filePath, UploadPolicy $uploadPolicy,  UploadOption $uploadOption)
286
+	public function multipartUpload($filePath, UploadPolicy $uploadPolicy, UploadOption $uploadOption)
287 287
 	{
288 288
 		$encodePath = iconv('UTF-8', 'GB2312', $filePath); //中文需要转换成gb2312,file_exist等函数才能识别
289 289
 		if (!file_exists($encodePath)) {
290 290
 			return $this->_errorResponse("FileNotExist", "file not exist");
291 291
 		}
292
-		$fileSize = filesize($encodePath);		// 文件大小
293
-		$blockSize = $uploadOption->blockSize;	// 文件分片大小
292
+		$fileSize = filesize($encodePath); // 文件大小
293
+		$blockSize = $uploadOption->blockSize; // 文件分片大小
294 294
 		$blockNum = intval(ceil($fileSize / $blockSize)); // 文件分片后的块数
295 295
 		$currentSize = $blockSize; // 当前文件块的大小
296 296
 		if ($uploadOption->getPartNumber() == $blockNum) {
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 	 * @param UploadOption $uploadOption 上传选项
309 309
 	 * @return array 分片上传的结果
310 310
 	 */
311
-	public function multipartUploadByData($blockData, UploadPolicy $uploadPolicy,  UploadOption $uploadOption)
311
+	public function multipartUploadByData($blockData, UploadPolicy $uploadPolicy, UploadOption $uploadOption)
312 312
 	{
313 313
 		$partNumber = $uploadOption->getPartNumber(); //php 5.3的版本使用empty()传递函数返回值会报错。所以为了兼容,增加临时变量
314 314
 		// 检查分片上传所需的参数是否设置正确
@@ -316,8 +316,8 @@  discard block
 block discarded – undo
316 316
 			return $this->_errorResponse("MultipartUploadError", "multipart upload's parameters(id,uploadId,partNumber) error");
317 317
 		}
318 318
 		$uploadOption->setContent($blockData); // 设置待上传的文件块
319
-		$uploadOption->optionType = UpOptionType::BLOCK_RUN_UPLOAD;		//分片上传过程中的Option类型
320
-		$url = $this->upload_host . Conf::UPLOAD_API_BLOCK_UPLOAD;		//分片上传过程中的API
319
+		$uploadOption->optionType = UpOptionType::BLOCK_RUN_UPLOAD; //分片上传过程中的Option类型
320
+		$url = $this->upload_host . Conf::UPLOAD_API_BLOCK_UPLOAD; //分片上传过程中的API
321 321
 		$httpRes = $this->_send_request('POST', $url, $uploadPolicy, $uploadOption);
322 322
 		if (isset($httpRes['partNumber']) && isset($httpRes['eTag'])) {
323 323
 			$uploadOption->addPartNumberAndETag($httpRes['partNumber'], $httpRes['eTag']);
@@ -331,14 +331,14 @@  discard block
 block discarded – undo
331 331
 	 * @param UploadOption $uploadOption 上传选项
332 332
 	 * @return array 分片上传完成的结果
333 333
 	 */
334
-	public function multipartComplete(UploadPolicy $uploadPolicy,  UploadOption $uploadOption)
334
+	public function multipartComplete(UploadPolicy $uploadPolicy, UploadOption $uploadOption)
335 335
 	{ // 检查分片上传所需的参数是否设置正确
336 336
 		$fileMd5 = $uploadOption->getMd5(); //php 5.3的版本使用empty()传递函数返回值会报错。所以为了兼容,增加临时变量
337 337
 		if (!$uploadOption->checkMutipartParas() || empty($fileMd5)) {
338 338
 			return $this->_errorResponse("MultipartCompleteError", "multipart upload's parameters(id,uploadId,md5) error");
339 339
 		}
340
-		$url = $this->upload_host . Conf::UPLOAD_API_BLOCK_COMPLETE;			//完成分片上传任务的API
341
-		$uploadOption->optionType = UpOptionType::BLOCK_COMPLETE_UPLOAD;		//完成分片上传任务时的Option类型
340
+		$url = $this->upload_host . Conf::UPLOAD_API_BLOCK_COMPLETE; //完成分片上传任务的API
341
+		$uploadOption->optionType = UpOptionType::BLOCK_COMPLETE_UPLOAD; //完成分片上传任务时的Option类型
342 342
 		return $this->_send_request('POST', $url, $uploadPolicy, $uploadOption);
343 343
 	}
344 344
 
@@ -348,13 +348,13 @@  discard block
 block discarded – undo
348 348
 	 * @param UploadOption $uploadOption 上传选项
349 349
 	 * @return array 分片上传完成的结果
350 350
 	 */
351
-	public function multipartCancel(UploadPolicy $uploadPolicy,  UploadOption $uploadOption)
351
+	public function multipartCancel(UploadPolicy $uploadPolicy, UploadOption $uploadOption)
352 352
 	{
353 353
 		if (!$uploadOption->checkMutipartParas()) {
354 354
 			return $this->_errorResponse("MultipartCancelError", "multipart upload's parameters(id,uploadId) error");
355 355
 		}
356
-		$url = $this->upload_host . Conf::UPLOAD_API_BLOCK_CANCEL;		//取消分片任务的API
357
-		$uploadOption->optionType = UpOptionType::BLOCK_CANCEL_UPLOAD;	//取消分片任务时的Option类型
356
+		$url = $this->upload_host . Conf::UPLOAD_API_BLOCK_CANCEL; //取消分片任务的API
357
+		$uploadOption->optionType = UpOptionType::BLOCK_CANCEL_UPLOAD; //取消分片任务时的Option类型
358 358
 		return $this->_send_request('POST', $url, $uploadPolicy, $uploadOption);
359 359
 	}
360 360
 
@@ -382,17 +382,17 @@  discard block
 block discarded – undo
382 382
 				list($contentType, $httpBody) = $this->BuildMultipartForm($uploadOption);
383 383
 				$length = @strlen($httpBody);
384 384
 				array_push($_headers, "Content-Type: {$contentType}");
385
-				curl_setopt($ch, CURLOPT_POSTFIELDS, $httpBody);			//请求体
385
+				curl_setopt($ch, CURLOPT_POSTFIELDS, $httpBody); //请求体
386 386
 			}
387 387
 			array_push($_headers, "Content-Length: {$length}");
388
-			curl_setopt($ch, CURLOPT_HEADER, 1);							//设置头部
389
-			curl_setopt($ch, CURLOPT_HTTPHEADER, $_headers);				//请求头
390
-			curl_setopt($ch, CURLOPT_TIMEOUT, $uploadOption->timeout);	//持续时长
391
-			curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);	            //连接超时时长
388
+			curl_setopt($ch, CURLOPT_HEADER, 1); //设置头部
389
+			curl_setopt($ch, CURLOPT_HTTPHEADER, $_headers); //请求头
390
+			curl_setopt($ch, CURLOPT_TIMEOUT, $uploadOption->timeout); //持续时长
391
+			curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); //连接超时时长
392 392
 			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //成功,只返回结果,不自动输出任何内容。如果失败返回FALSE
393 393
 			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
394 394
 			curl_setopt($ch, CURLOPT_URL, $url);
395
-			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);			//自定义请求
395
+			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); //自定义请求
396 396
 			//设置请求方式(GET或POST等)
397 397
 			if ($method == 'PUT' || $method == 'POST') {
398 398
 				curl_setopt($ch, CURLOPT_POST, 1);
@@ -413,10 +413,10 @@  discard block
 block discarded – undo
413 413
 			} else {
414 414
 				//解析返回结果,并判断是否上传成功
415 415
 				$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
416
-				$success = ($http_code == 200) ? true : false;					//判断是否上传成功
416
+				$success = ($http_code == 200) ? true : false; //判断是否上传成功
417 417
 				$resStr = explode("\r\n\r\n", $response);
418 418
 				$resBody = isset($resStr[1]) ? $resStr[1] : '';
419
-				$resArray = json_decode($resBody, true);						//解析得到结果
419
+				$resArray = json_decode($resBody, true); //解析得到结果
420 420
 				$result = (empty($resArray) ? $result : $resArray);
421 421
 			}
422 422
 		} catch (Exception $e) {
Please login to merge, or discard this patch.
sdk/Core/ManageClient.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 		$_headers = array('Expect:');
327 327
 		$date = $this->currentMilliSecond(); //得到当前的时间戳,毫秒
328 328
 		array_push($_headers, "Date: {$date}");
329
-		$authorization = $this->_getAuthorization($uri, $date, $httpBody);	//Http的Body需要加入管理鉴权
329
+		$authorization = $this->_getAuthorization($uri, $date, $httpBody); //Http的Body需要加入管理鉴权
330 330
 		array_push($_headers, "Authorization: {$authorization}");
331 331
 		array_push($_headers, "User-Agent: {$this->_getUserAgent()}");
332 332
 		if (!is_null($headers) && is_array($headers)) {
@@ -345,13 +345,13 @@  discard block
 block discarded – undo
345 345
 				array_push($_headers, "Content-Type: application/x-www-form-urlencoded");
346 346
 			}
347 347
 			array_push($_headers, "Content-Length: {$length}");
348
-			curl_setopt($ch, CURLOPT_HEADER, 1);							//设置头部
349
-			curl_setopt($ch, CURLOPT_HTTPHEADER, $_headers);				//请求头
350
-			curl_setopt($ch, CURLOPT_TIMEOUT, Conf::HTTP_TIMEOUT);		//超时时长
351
-			curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);	            //连接超时时长
348
+			curl_setopt($ch, CURLOPT_HEADER, 1); //设置头部
349
+			curl_setopt($ch, CURLOPT_HTTPHEADER, $_headers); //请求头
350
+			curl_setopt($ch, CURLOPT_TIMEOUT, Conf::HTTP_TIMEOUT); //超时时长
351
+			curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); //连接超时时长
352 352
 			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //成功,只返回结果,不自动输出任何内容。如果失败返回FALSE
353 353
 			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
354
-			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);			//自定义请求
354
+			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); //自定义请求
355 355
 			//设置请求方式(GET或POST等)
356 356
 			if ($method == 'PUT' || $method == 'POST') {
357 357
 				curl_setopt($ch, CURLOPT_POST, 1);
@@ -366,10 +366,10 @@  discard block
 block discarded – undo
366 366
 			} else {
367 367
 				//解析返回结果,并判断是否上传成功
368 368
 				$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
369
-				$success = ($http_code == 200) ? true : false;					//判断是否上传成功
369
+				$success = ($http_code == 200) ? true : false; //判断是否上传成功
370 370
 				$resStr = explode("\r\n\r\n", $response);
371 371
 				$resBody = isset($resStr[1]) ? $resStr[1] : '';
372
-				$resArray = json_decode($resBody, true);						//解析得到结果
372
+				$resArray = json_decode($resBody, true); //解析得到结果
373 373
 				$result = (empty($resArray)) ? array() : $resArray;
374 374
 			}
375 375
 		} catch (Exception $e) {
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 	protected function currentMilliSecond()
442 442
 	{
443 443
 		list($microSec, $stampSec) = explode(' ', microtime());
444
-		$tempMilli =  sprintf('%03s', intval($microSec * 1000));
444
+		$tempMilli = sprintf('%03s', intval($microSec * 1000));
445 445
 		$currentMilli = $stampSec . $tempMilli;
446 446
 		return $currentMilli;
447 447
 	}
Please login to merge, or discard this patch.
Braces   +24 added lines, -16 removed lines patch added patch discarded remove patch
@@ -137,10 +137,12 @@  discard block
 block discarded – undo
137 137
 	 */
138 138
 	public function existsFolder($namespace, $dir)
139 139
 	{
140
-		if (empty($namespace) || empty($dir))
141
-			return $this->_errorResponse("InvalidArgument", "namespace or dir is empty");
142
-		if (strpos($dir, '/') !== 0)
143
-			$dir = '/' . $dir;
140
+		if (empty($namespace) || empty($dir)) {
141
+					return $this->_errorResponse("InvalidArgument", "namespace or dir is empty");
142
+		}
143
+		if (strpos($dir, '/') !== 0) {
144
+					$dir = '/' . $dir;
145
+		}
144 146
 		$resourceInfo = new ResourceInfo($namespace, $dir);
145 147
 		$resourceId = $resourceInfo->buildResourceId(); //得到资源ID
146 148
 		$uri = '/' . Conf::MANAGE_API_VERSION . '/folders/' . $resourceId . '/exist';
@@ -155,10 +157,12 @@  discard block
 block discarded – undo
155 157
 	 */
156 158
 	public function createDir($namespace, $dir)
157 159
 	{
158
-		if (empty($namespace) || empty($dir))
159
-			return $this->_errorResponse("InvalidArgument", "namespace or dir is empty");
160
-		if (strpos($dir, '/') !== 0)
161
-			$dir = '/' . $dir;
160
+		if (empty($namespace) || empty($dir)) {
161
+					return $this->_errorResponse("InvalidArgument", "namespace or dir is empty");
162
+		}
163
+		if (strpos($dir, '/') !== 0) {
164
+					$dir = '/' . $dir;
165
+		}
162 166
 		$resourceInfo = new ResourceInfo($namespace, $dir);
163 167
 		$resourceId = $resourceInfo->buildResourceId(); //得到资源ID
164 168
 		$uri = '/' . Conf::MANAGE_API_VERSION . '/folders/' . $resourceId;
@@ -197,10 +201,12 @@  discard block
 block discarded – undo
197 201
 	 */
198 202
 	public function deleteDir($namespace, $dir)
199 203
 	{
200
-		if (empty($namespace) || empty($dir))
201
-			return $this->_errorResponse("InvalidArgument", "namespace or dir is empty");
202
-		if (strpos($dir, '/') !== 0)
203
-			$dir = '/' . $dir;
204
+		if (empty($namespace) || empty($dir)) {
205
+					return $this->_errorResponse("InvalidArgument", "namespace or dir is empty");
206
+		}
207
+		if (strpos($dir, '/') !== 0) {
208
+					$dir = '/' . $dir;
209
+		}
204 210
 		$resourceInfo = new ResourceInfo($namespace, $dir);
205 211
 		$resourceId = $resourceInfo->buildResourceId(); //得到资源ID
206 212
 		$uri = '/' . Conf::MANAGE_API_VERSION . '/folders/' . $resourceId;
@@ -260,8 +266,9 @@  discard block
 block discarded – undo
260 266
 	 */
261 267
 	public function mediaEncodeQuery($taskId)
262 268
 	{
263
-		if (empty($taskId))
264
-			return $this->_errorResponse("InvalidArgument", "taskId is empty");
269
+		if (empty($taskId)) {
270
+					return $this->_errorResponse("InvalidArgument", "taskId is empty");
271
+		}
265 272
 		$uri = '/' . Conf::MEDIA_ENCODE_VERSION . '/mediaEncodeResult/' . $taskId;
266 273
 		return $this->_send_request('GET', $uri);
267 274
 	}
@@ -287,8 +294,9 @@  discard block
 block discarded – undo
287 294
 	 */
288 295
 	public function vSnapshotQuery($taskId)
289 296
 	{
290
-		if (empty($taskId))
291
-			return $this->_errorResponse("InvalidArgument", "taskId is empty");
297
+		if (empty($taskId)) {
298
+					return $this->_errorResponse("InvalidArgument", "taskId is empty");
299
+		}
292 300
 		$uri = '/' . Conf::MANAGE_API_VERSION . '/snapshotResult/' . $taskId;
293 301
 		return $this->_send_request('GET', $uri);
294 302
 	}
Please login to merge, or discard this patch.
sdk/Utils/MediaEncodeOption.php 2 patches
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -2,17 +2,17 @@  discard block
 block discarded – undo
2 2
 namespace AliMedia\Utils;
3 3
 
4 4
 /**多媒体转码的参数*/
5
-class MediaEncodeOption extends MediaResOption{
5
+class MediaEncodeOption extends MediaResOption {
6 6
 	/* 以下属性是"视频转码"方法必须的属性 */
7
-	private $encodeTemplate;          //模板名称。可以设置系统或者用户自定义模板。用户模板名称可以登录后台查看和设置,系统模板见附录系统模板列表
8
-	public $usePreset = 0;            //是否使用系统模板。默认0。如果为1,则encodeTemplate必须设置系统模板名称
9
-	public $force = 0;                //是否强制覆盖。默认0,如果为1,当output文件已经存在的时候会强制覆盖,否则不执行转码并结束任务
7
+	private $encodeTemplate; //模板名称。可以设置系统或者用户自定义模板。用户模板名称可以登录后台查看和设置,系统模板见附录系统模板列表
8
+	public $usePreset = 0; //是否使用系统模板。默认0。如果为1,则encodeTemplate必须设置系统模板名称
9
+	public $force = 0; //是否强制覆盖。默认0,如果为1,当output文件已经存在的时候会强制覆盖,否则不执行转码并结束任务
10 10
 	/* 以下属性是"视频转码"方法可选的属性 */
11
-	private $watermark;               //水印资源
12
-	private $watermarkTemplate;       //用户自定义水印模板
13
-	private $notifyUrl;               //通知url,任务结束之后会调用这个url
14
-	private $seek;                    //截取音视频的开始位置
15
-	private $duration;                //截取音视频的长度
11
+	private $watermark; //水印资源
12
+	private $watermarkTemplate; //用户自定义水印模板
13
+	private $notifyUrl; //通知url,任务结束之后会调用这个url
14
+	private $seek; //截取音视频的开始位置
15
+	private $duration; //截取音视频的长度
16 16
 
17 17
 	/**设置转码模板。必须。模板在顽兔控制台"多媒体处理"中配置*/
18 18
 	public function setEncodeTemplate($encodeTemplate) {
@@ -20,17 +20,17 @@  discard block
 block discarded – undo
20 20
 	}
21 21
 	/**检测多媒体转码选项是否合法。如果合法,则返回http请求体<p> 返回格式{$isValid, $message, $httpBody}*/
22 22
 	public function checkOptionParameters() {
23
-		list ( $valid, $msg ) = parent::checkOptionParameters(); //检测输入输出资源是否合法
24
-		if ( !$valid )
25
-			return array ( $valid, $msg, null );
26
-		if ( empty($this->encodeTemplate) )
27
-			return array ( false, "encodeTemplate is empty.", null ); // 判断是否设置输入输出文件,或者转码模板
28
-		if( ($this->usePreset!=0 && $this->usePreset!=1) || ($this->force!=0 && $this->force!=1) )
29
-			return array ( false, "parameters 'usePreset' or 'force' is invalid.", null ); // 判断usePreset和force参数是否为0或1
23
+		list ($valid, $msg) = parent::checkOptionParameters(); //检测输入输出资源是否合法
24
+		if (!$valid)
25
+			return array($valid, $msg, null);
26
+		if (empty($this->encodeTemplate))
27
+			return array(false, "encodeTemplate is empty.", null); // 判断是否设置输入输出文件,或者转码模板
28
+		if (($this->usePreset != 0 && $this->usePreset != 1) || ($this->force != 0 && $this->force != 1))
29
+			return array(false, "parameters 'usePreset' or 'force' is invalid.", null); // 判断usePreset和force参数是否为0或1
30 30
 		return $this->getOptionsHttpBody(); //返回http请求体
31 31
 	}
32 32
 	/**构建多媒体转码所需的http请求体*/
33
-	public function getOptionsHttpBody(){
33
+	public function getOptionsHttpBody() {
34 34
 		//必须的参数
35 35
 		$httpBody = 'input=' . $this->getInputResId();
36 36
 		$httpBody .= '&output=' . $this->getOutputResId();
@@ -38,22 +38,22 @@  discard block
 block discarded – undo
38 38
 		$httpBody .= '&usePreset=' . $this->usePreset;
39 39
 		$httpBody .= '&force=' . $this->force;
40 40
 		// 可选的参数
41
-		if (isset ( $this->watermark ))
42
-			$httpBody .= '&watermark=' . $this->watermark->buildResourceId ();
43
-		if (isset ( $this->watermarkTemplate ))
41
+		if (isset ($this->watermark))
42
+			$httpBody .= '&watermark=' . $this->watermark->buildResourceId();
43
+		if (isset ($this->watermarkTemplate))
44 44
 			$httpBody .= '&watermarkTemplate=' . urlencode($this->watermarkTemplate);
45
-		if (isset ( $this->notifyUrl ))
45
+		if (isset ($this->notifyUrl))
46 46
 			$httpBody .= '&notifyUrl=' . urlencode($this->notifyUrl);
47
-		if (isset ( $this->seek ))
48
-			$httpBody .= '&seek=' .  $this->seek;
49
-		if (isset ( $this->duration ))
47
+		if (isset ($this->seek))
48
+			$httpBody .= '&seek=' . $this->seek;
49
+		if (isset ($this->duration))
50 50
 			$httpBody .= '&duration=' . $this->duration;
51
-		return array ( true, "valid", $httpBody ); //视频转码参数合法,返回http请求体
51
+		return array(true, "valid", $httpBody); //视频转码参数合法,返回http请求体
52 52
 	}
53 53
 	/*######################以下是可选的参数set方法#######################*/
54 54
 	/**设置水印。可选*/
55
-	public function setWatermark($namespace=null, $dir=null, $name=null) {
56
-		$this->watermark = new ResourceInfo($namespace,$dir,$name);
55
+	public function setWatermark($namespace = null, $dir = null, $name = null) {
56
+		$this->watermark = new ResourceInfo($namespace, $dir, $name);
57 57
 	}
58 58
 	/**设置用户自定义水印模板。可选*/
59 59
 	public function setWatermarkTemplate($watermarkTemplate) {
@@ -73,30 +73,30 @@  discard block
 block discarded – undo
73 73
 	}
74 74
 }
75 75
 /**视频截图的参数*/
76
-class SnapShotOption extends MediaResOption{
76
+class SnapShotOption extends MediaResOption {
77 77
 	/** 视频截图的位置,单位为毫秒。该属性必须*/
78 78
 	private $time;
79 79
 	/** 通知url,任务结束之后会调用这个url。该属性可选 */
80 80
 	private $notifyUrl;
81 81
 	/**检测视频截图参数是否合法。如果合法,则返回http请求体<p> 返回格式{$isValid, $message, $httpBody}*/
82 82
 	public function checkOptionParameters() {
83
-		list ( $valid, $msg ) = parent::checkOptionParameters(); //检测输入输出资源是否合法
84
-		if ( !$valid )
85
-			return array ( $valid, $msg, null );
86
-		if ( empty($this->time) || !is_int($this->time) || $this->time<0)
87
-			return array ( false, "time is empty or invalid.", null ); // 是否设置时间,且时间是否合法
83
+		list ($valid, $msg) = parent::checkOptionParameters(); //检测输入输出资源是否合法
84
+		if (!$valid)
85
+			return array($valid, $msg, null);
86
+		if (empty($this->time) || !is_int($this->time) || $this->time < 0)
87
+			return array(false, "time is empty or invalid.", null); // 是否设置时间,且时间是否合法
88 88
 		return $this->getOptionsHttpBody(); //返回http请求体
89 89
 	}
90 90
 	/**构建多媒体转码所需的http请求体*/
91
-	public function getOptionsHttpBody(){
91
+	public function getOptionsHttpBody() {
92 92
 		//必须的参数
93 93
 		$httpBody = 'input=' . $this->getInputResId();
94 94
 		$httpBody .= '&output=' . $this->getOutputResId();
95 95
 		$httpBody .= '&time=' . $this->time;
96 96
 		// 可选的参数
97
-		if (isset ( $this->notifyUrl ))
98
-			$httpBody .= '&notifyUrl=' . urlencode($this->notifyUrl) ;
99
-		return array ( true, "valid", $httpBody ); //视频转码参数合法,返回http请求体
97
+		if (isset ($this->notifyUrl))
98
+			$httpBody .= '&notifyUrl=' . urlencode($this->notifyUrl);
99
+		return array(true, "valid", $httpBody); //视频转码参数合法,返回http请求体
100 100
 	}
101 101
 
102 102
 	/**设置视频截图的位置,单位为毫秒。改参数必须设置*/
@@ -110,27 +110,27 @@  discard block
 block discarded – undo
110 110
 }
111 111
 /**多媒体操作的输入输出资源信息。视频截图和视频转码都继承该类*/
112 112
 abstract class MediaResOption {
113
-	private $input;                  //输入的资源
114
-	private $output;                 //输出的资源
113
+	private $input; //输入的资源
114
+	private $output; //输出的资源
115 115
 	/**设置输入的文件。*/
116
-	public function setInputResource($namespace=null, $dir=null, $name=null) {
117
-		$this->input = new ResourceInfo($namespace,$dir,$name);
116
+	public function setInputResource($namespace = null, $dir = null, $name = null) {
117
+		$this->input = new ResourceInfo($namespace, $dir, $name);
118 118
 	}
119 119
 	/**设置输出的文件。*/
120
-	public function setOutputResource($namespace=null, $dir=null, $name=null) {
121
-		$this->output = new ResourceInfo($namespace,$dir,$name);
120
+	public function setOutputResource($namespace = null, $dir = null, $name = null) {
121
+		$this->output = new ResourceInfo($namespace, $dir, $name);
122 122
 	}
123 123
 	/**检测参数选项是否合法*/
124 124
 	public function checkOptionParameters() {
125
-		if ( empty($this->input) || empty($this->output) )
126
-			return array ( false, "input or output resources is empty." ); // 判断是否设置输入输出文件,或者转码模板
127
-		list ( $valid, $msg ) = $this->input->checkResourceInfo(true,true);//检测输入的资源信息是否合法
128
-		if(!$valid)
129
-			return array ( $valid, $msg );
130
-		list ( $valid, $msg ) = $this->output->checkResourceInfo(true,true);//检测输入的资源信息是否合法
131
-		if(!$valid)
132
-			return array ( $valid, $msg );
133
-		return array( true, null);
125
+		if (empty($this->input) || empty($this->output))
126
+			return array(false, "input or output resources is empty."); // 判断是否设置输入输出文件,或者转码模板
127
+		list ($valid, $msg) = $this->input->checkResourceInfo(true, true); //检测输入的资源信息是否合法
128
+		if (!$valid)
129
+			return array($valid, $msg);
130
+		list ($valid, $msg) = $this->output->checkResourceInfo(true, true); //检测输入的资源信息是否合法
131
+		if (!$valid)
132
+			return array($valid, $msg);
133
+		return array(true, null);
134 134
 	}
135 135
 	public function getInputResId() {
136 136
 		return $this->input->buildResourceId();
Please login to merge, or discard this patch.
Braces   +46 added lines, -28 removed lines patch added patch discarded remove patch
@@ -21,12 +21,17 @@  discard block
 block discarded – undo
21 21
 	/**检测多媒体转码选项是否合法。如果合法,则返回http请求体<p> 返回格式{$isValid, $message, $httpBody}*/
22 22
 	public function checkOptionParameters() {
23 23
 		list ( $valid, $msg ) = parent::checkOptionParameters(); //检测输入输出资源是否合法
24
-		if ( !$valid )
25
-			return array ( $valid, $msg, null );
26
-		if ( empty($this->encodeTemplate) )
27
-			return array ( false, "encodeTemplate is empty.", null ); // 判断是否设置输入输出文件,或者转码模板
28
-		if( ($this->usePreset!=0 && $this->usePreset!=1) || ($this->force!=0 && $this->force!=1) )
29
-			return array ( false, "parameters 'usePreset' or 'force' is invalid.", null ); // 判断usePreset和force参数是否为0或1
24
+		if ( !$valid ) {
25
+					return array ( $valid, $msg, null );
26
+		}
27
+		if ( empty($this->encodeTemplate) ) {
28
+					return array ( false, "encodeTemplate is empty.", null );
29
+		}
30
+		// 判断是否设置输入输出文件,或者转码模板
31
+		if( ($this->usePreset!=0 && $this->usePreset!=1) || ($this->force!=0 && $this->force!=1) ) {
32
+					return array ( false, "parameters 'usePreset' or 'force' is invalid.", null );
33
+		}
34
+		// 判断usePreset和force参数是否为0或1
30 35
 		return $this->getOptionsHttpBody(); //返回http请求体
31 36
 	}
32 37
 	/**构建多媒体转码所需的http请求体*/
@@ -38,16 +43,21 @@  discard block
 block discarded – undo
38 43
 		$httpBody .= '&usePreset=' . $this->usePreset;
39 44
 		$httpBody .= '&force=' . $this->force;
40 45
 		// 可选的参数
41
-		if (isset ( $this->watermark ))
42
-			$httpBody .= '&watermark=' . $this->watermark->buildResourceId ();
43
-		if (isset ( $this->watermarkTemplate ))
44
-			$httpBody .= '&watermarkTemplate=' . urlencode($this->watermarkTemplate);
45
-		if (isset ( $this->notifyUrl ))
46
-			$httpBody .= '&notifyUrl=' . urlencode($this->notifyUrl);
47
-		if (isset ( $this->seek ))
48
-			$httpBody .= '&seek=' .  $this->seek;
49
-		if (isset ( $this->duration ))
50
-			$httpBody .= '&duration=' . $this->duration;
46
+		if (isset ( $this->watermark )) {
47
+					$httpBody .= '&watermark=' . $this->watermark->buildResourceId ();
48
+		}
49
+		if (isset ( $this->watermarkTemplate )) {
50
+					$httpBody .= '&watermarkTemplate=' . urlencode($this->watermarkTemplate);
51
+		}
52
+		if (isset ( $this->notifyUrl )) {
53
+					$httpBody .= '&notifyUrl=' . urlencode($this->notifyUrl);
54
+		}
55
+		if (isset ( $this->seek )) {
56
+					$httpBody .= '&seek=' .  $this->seek;
57
+		}
58
+		if (isset ( $this->duration )) {
59
+					$httpBody .= '&duration=' . $this->duration;
60
+		}
51 61
 		return array ( true, "valid", $httpBody ); //视频转码参数合法,返回http请求体
52 62
 	}
53 63
 	/*######################以下是可选的参数set方法#######################*/
@@ -81,10 +91,13 @@  discard block
 block discarded – undo
81 91
 	/**检测视频截图参数是否合法。如果合法,则返回http请求体<p> 返回格式{$isValid, $message, $httpBody}*/
82 92
 	public function checkOptionParameters() {
83 93
 		list ( $valid, $msg ) = parent::checkOptionParameters(); //检测输入输出资源是否合法
84
-		if ( !$valid )
85
-			return array ( $valid, $msg, null );
86
-		if ( empty($this->time) || !is_int($this->time) || $this->time<0)
87
-			return array ( false, "time is empty or invalid.", null ); // 是否设置时间,且时间是否合法
94
+		if ( !$valid ) {
95
+					return array ( $valid, $msg, null );
96
+		}
97
+		if ( empty($this->time) || !is_int($this->time) || $this->time<0) {
98
+					return array ( false, "time is empty or invalid.", null );
99
+		}
100
+		// 是否设置时间,且时间是否合法
88 101
 		return $this->getOptionsHttpBody(); //返回http请求体
89 102
 	}
90 103
 	/**构建多媒体转码所需的http请求体*/
@@ -94,8 +107,9 @@  discard block
 block discarded – undo
94 107
 		$httpBody .= '&output=' . $this->getOutputResId();
95 108
 		$httpBody .= '&time=' . $this->time;
96 109
 		// 可选的参数
97
-		if (isset ( $this->notifyUrl ))
98
-			$httpBody .= '&notifyUrl=' . urlencode($this->notifyUrl) ;
110
+		if (isset ( $this->notifyUrl )) {
111
+					$httpBody .= '&notifyUrl=' . urlencode($this->notifyUrl) ;
112
+		}
99 113
 		return array ( true, "valid", $httpBody ); //视频转码参数合法,返回http请求体
100 114
 	}
101 115
 
@@ -122,14 +136,18 @@  discard block
 block discarded – undo
122 136
 	}
123 137
 	/**检测参数选项是否合法*/
124 138
 	public function checkOptionParameters() {
125
-		if ( empty($this->input) || empty($this->output) )
126
-			return array ( false, "input or output resources is empty." ); // 判断是否设置输入输出文件,或者转码模板
139
+		if ( empty($this->input) || empty($this->output) ) {
140
+					return array ( false, "input or output resources is empty." );
141
+		}
142
+		// 判断是否设置输入输出文件,或者转码模板
127 143
 		list ( $valid, $msg ) = $this->input->checkResourceInfo(true,true);//检测输入的资源信息是否合法
128
-		if(!$valid)
129
-			return array ( $valid, $msg );
144
+		if(!$valid) {
145
+					return array ( $valid, $msg );
146
+		}
130 147
 		list ( $valid, $msg ) = $this->output->checkResourceInfo(true,true);//检测输入的资源信息是否合法
131
-		if(!$valid)
132
-			return array ( $valid, $msg );
148
+		if(!$valid) {
149
+					return array ( $valid, $msg );
150
+		}
133 151
 		return array( true, null);
134 152
 	}
135 153
 	public function getInputResId() {
Please login to merge, or discard this patch.
sdk/Utils/UploadOption.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -9,34 +9,34 @@  discard block
 block discarded – undo
9 9
 	public $optionType;
10 10
 
11 11
 	/*以下属性是上传时的可选参数。即Rest API中Http请求Body中所需的可选参数*/
12
-	public $dir;                                    // 顽兔空间的图片路径(如果UploadPolicy中不指定dir属性,则生效)
13
-	public $name;                                   // 上传到服务端的文件名(如果UploadPolicy中不指定name属性,则生效)
14
-	public $metaArray;                              // 用户自定义的文件meta信息("meta-"为参数前缀, "*"为用户用于渲染的自定义Meta信息名)
15
-	public $varArray;                               // 用户自定义的魔法变量("var-"为参数前缀, "*"为用户用于渲染的自定义魔法变量名)
16
-	private $md5;                                   // 文件md5值(推荐提供此参数进行一致性检查)
17
-	private $size;                                  // 文件大小
18
-	private $content;                               // 文件内容(在http请求体Body中必须位于参数的最后一位)
12
+	public $dir; // 顽兔空间的图片路径(如果UploadPolicy中不指定dir属性,则生效)
13
+	public $name; // 上传到服务端的文件名(如果UploadPolicy中不指定name属性,则生效)
14
+	public $metaArray; // 用户自定义的文件meta信息("meta-"为参数前缀, "*"为用户用于渲染的自定义Meta信息名)
15
+	public $varArray; // 用户自定义的魔法变量("var-"为参数前缀, "*"为用户用于渲染的自定义魔法变量名)
16
+	private $md5; // 文件md5值(推荐提供此参数进行一致性检查)
17
+	private $size; // 文件大小
18
+	private $content; // 文件内容(在http请求体Body中必须位于参数的最后一位)
19 19
 
20 20
 	/*以下属性是用户根据自己应用需求,可选的配置*/
21
-	public $blockSize;                              // 文件分片的大小。针对分片上传。
22
-	public $timeout;                                // 进行http连接的超时时间
23
-	public $httpReTry;                              // http失败自动重试。0 or 1
21
+	public $blockSize; // 文件分片的大小。针对分片上传。
22
+	public $timeout; // 进行http连接的超时时间
23
+	public $httpReTry; // http失败自动重试。0 or 1
24 24
 
25 25
 	/*以下属性是用于分片上传时的参数,仅用于分片上传。用户在调用分片上传时可以选择配置。*/
26
-	private $uploadId;                              // OSS分片上传ID(OSS用于区分上传的id)
27
-	private $uniqueId;                              // 服务上传唯一ID(多媒体服务用于区分上传的id)
28
-	private $partNumber;                            // 分片文件块上传成功后返回的文件块编号
29
-	private $eTag;                                  // 分片文件块上传成功后返回的Tag标签(由md5和其他标记组成)
30
-	private $array_PartNum_ETag;                    // 分片上传服务端返回的所有 块编号partNumber 和 标记ETag
26
+	private $uploadId; // OSS分片上传ID(OSS用于区分上传的id)
27
+	private $uniqueId; // 服务上传唯一ID(多媒体服务用于区分上传的id)
28
+	private $partNumber; // 分片文件块上传成功后返回的文件块编号
29
+	private $eTag; // 分片文件块上传成功后返回的Tag标签(由md5和其他标记组成)
30
+	private $array_PartNum_ETag; // 分片上传服务端返回的所有 块编号partNumber 和 标记ETag
31 31
 
32 32
 	public function __construct()
33 33
 	{
34 34
 		$this->optionType = UpOptionType::COMMON_UPLOAD_TYPE; //默认普通上传类型
35 35
 		$this->metaArray = array();
36 36
 		$this->varArray = array();
37
-		$this->blockSize = Conf::BLOCK_DEFF_SIZE;   //默认2M
38
-		$this->timeout = Conf::HTTP_TIMEOUT;        //默认超时30s
39
-		$this->httpReTry = Conf::HTTP_RETRY;       //默认重试
37
+		$this->blockSize = Conf::BLOCK_DEFF_SIZE; //默认2M
38
+		$this->timeout = Conf::HTTP_TIMEOUT; //默认超时30s
39
+		$this->httpReTry = Conf::HTTP_RETRY; //默认重试
40 40
 		$this->array_PartNum_ETag = array();
41 41
 	}
42 42
 	/**得到上传时http请求体所需的参数*/
@@ -172,9 +172,9 @@  discard block
 block discarded – undo
172 172
 class UpOptionType
173 173
 {
174 174
 	//下面的常量用于标识UploadOption对象适用的类型
175
-	const COMMON_UPLOAD_TYPE = 0;		//普通上传时的UploadOption类型
176
-	const BLOCK_INIT_UPLOAD = 1;		//分片初始化时的UploadOption类型
177
-	const BLOCK_RUN_UPLOAD = 2;			//分片上传过程中的UploadOption类型
178
-	const BLOCK_COMPLETE_UPLOAD = 3;	//分片上传完成时的UploadOption类型
179
-	const BLOCK_CANCEL_UPLOAD = 4;		//分片上传取消时的UploadOption类型
175
+	const COMMON_UPLOAD_TYPE = 0; //普通上传时的UploadOption类型
176
+	const BLOCK_INIT_UPLOAD = 1; //分片初始化时的UploadOption类型
177
+	const BLOCK_RUN_UPLOAD = 2; //分片上传过程中的UploadOption类型
178
+	const BLOCK_COMPLETE_UPLOAD = 3; //分片上传完成时的UploadOption类型
179
+	const BLOCK_CANCEL_UPLOAD = 4; //分片上传取消时的UploadOption类型
180 180
 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -60,10 +60,12 @@
 block discarded – undo
60 60
 	private function getParas_Common_BlockInit()
61 61
 	{
62 62
 		$paraArray = array();
63
-		if (isset($this->dir))
64
-			$paraArray['dir'] = $this->dir;
65
-		if (isset($this->name))
66
-			$paraArray['name'] = $this->name;
63
+		if (isset($this->dir)) {
64
+					$paraArray['dir'] = $this->dir;
65
+		}
66
+		if (isset($this->name)) {
67
+					$paraArray['name'] = $this->name;
68
+		}
67 69
 		$paraArray['md5'] = md5($this->content); // 计算文件md5
68 70
 		$paraArray['size'] = strlen($this->content); // 计算文件大小
69 71
 		$paraArray['content'] = $this->content;
Please login to merge, or discard this patch.
sdk/Utils/UploadPolicy.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -5,47 +5,47 @@
 block discarded – undo
5 5
 
6 6
 class UploadPolicy
7 7
 {
8
-    /*如下属性是必须的[The following attributes are required]*/
9
-    public $namespace;                              // 多媒体服务的空间名[media namespace name]
10
-    public $bucket;                                 // OSS的空间名[media bucket name]
11
-    public $insertOnly;                             // 是否可覆盖[upload mode. it's not allowd uploading the same name files]
12
-    public $expiration;                             // 过期时间[expiration time, unix time, in milliseconds]
8
+	/*如下属性是必须的[The following attributes are required]*/
9
+	public $namespace;                              // 多媒体服务的空间名[media namespace name]
10
+	public $bucket;                                 // OSS的空间名[media bucket name]
11
+	public $insertOnly;                             // 是否可覆盖[upload mode. it's not allowd uploading the same name files]
12
+	public $expiration;                             // 过期时间[expiration time, unix time, in milliseconds]
13 13
 
14
-    /*如下属性是可选的[The following attributes are optional]*/
15
-    public $detectMime = Conf::DETECT_MIME_TRUE;                             // 是否进行类型检测[is auto detecte media file mime type, default is true]
16
-    public $dir;                                    // 路径[media file dir, magic vars and custom vars are supported]
17
-    public $name;                                   // 上传到服务端的文件名[media file name, magic vars and custom vars are supported]
18
-    public $sizeLimit;                              // 文件大小限制[upload size limited, in bytes]
19
-    public $mimeLimit;                              // 文件类型限制[upload mime type limited]
20
-    public $callbackUrl;                            // 回调URL [callback urls, ip address is recommended]
21
-    public $callbackHost;                           // 回调时Host [callback host]
22
-    public $callbackBody;                           // 回调时Body [callback body, magic vars and custom vars are supported]
23
-    public $callbackBodyType;                       // 回调时Body类型 [callback body type, default is 'application/x-www-form-urlencoded; charset=utf-8']
24
-    public $returnUrl;                              // 上传完成之后,303跳转的Url [return url, when return code is 303]
25
-    public $returnBody;                             // 上传完成返回体 [return body, magic vars and custom vars are supported]
26
-    public $mediaEncode;                            // 上传音视频时,可以指定转码策略[media encode policy after upload task has been completed. it's json string]
14
+	/*如下属性是可选的[The following attributes are optional]*/
15
+	public $detectMime = Conf::DETECT_MIME_TRUE;                             // 是否进行类型检测[is auto detecte media file mime type, default is true]
16
+	public $dir;                                    // 路径[media file dir, magic vars and custom vars are supported]
17
+	public $name;                                   // 上传到服务端的文件名[media file name, magic vars and custom vars are supported]
18
+	public $sizeLimit;                              // 文件大小限制[upload size limited, in bytes]
19
+	public $mimeLimit;                              // 文件类型限制[upload mime type limited]
20
+	public $callbackUrl;                            // 回调URL [callback urls, ip address is recommended]
21
+	public $callbackHost;                           // 回调时Host [callback host]
22
+	public $callbackBody;                           // 回调时Body [callback body, magic vars and custom vars are supported]
23
+	public $callbackBodyType;                       // 回调时Body类型 [callback body type, default is 'application/x-www-form-urlencoded; charset=utf-8']
24
+	public $returnUrl;                              // 上传完成之后,303跳转的Url [return url, when return code is 303]
25
+	public $returnBody;                             // 上传完成返回体 [return body, magic vars and custom vars are supported]
26
+	public $mediaEncode;                            // 上传音视频时,可以指定转码策略[media encode policy after upload task has been completed. it's json string]
27 27
 
28
-    public function __construct($option)
29
-    {
30
-        if (!isset($option['expiration']) || !$option['expiration']) {
31
-            $option['expiration'] = -1;
32
-        }
28
+	public function __construct($option)
29
+	{
30
+		if (!isset($option['expiration']) || !$option['expiration']) {
31
+			$option['expiration'] = -1;
32
+		}
33 33
 
34
-        foreach ($option as $attribute => $value) {
35
-            $this->{$attribute} = $value;
36
-        }
37
-    }
34
+		foreach ($option as $attribute => $value) {
35
+			$this->{$attribute} = $value;
36
+		}
37
+	}
38 38
 
39
-    public function toArray()
40
-    {
41
-        return (array) $this;
42
-        $array = [];
43
-        foreach ($this as $attribute => $value) {
44
-            if ($value !== null) {
45
-                $array[$attribute] = $value;
46
-            }
47
-        }
39
+	public function toArray()
40
+	{
41
+		return (array) $this;
42
+		$array = [];
43
+		foreach ($this as $attribute => $value) {
44
+			if ($value !== null) {
45
+				$array[$attribute] = $value;
46
+			}
47
+		}
48 48
 
49
-        return $array;
50
-    }
49
+		return $array;
50
+	}
51 51
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -6,24 +6,24 @@
 block discarded – undo
6 6
 class UploadPolicy
7 7
 {
8 8
     /*如下属性是必须的[The following attributes are required]*/
9
-    public $namespace;                              // 多媒体服务的空间名[media namespace name]
10
-    public $bucket;                                 // OSS的空间名[media bucket name]
11
-    public $insertOnly;                             // 是否可覆盖[upload mode. it's not allowd uploading the same name files]
12
-    public $expiration;                             // 过期时间[expiration time, unix time, in milliseconds]
9
+    public $namespace; // 多媒体服务的空间名[media namespace name]
10
+    public $bucket; // OSS的空间名[media bucket name]
11
+    public $insertOnly; // 是否可覆盖[upload mode. it's not allowd uploading the same name files]
12
+    public $expiration; // 过期时间[expiration time, unix time, in milliseconds]
13 13
 
14 14
     /*如下属性是可选的[The following attributes are optional]*/
15
-    public $detectMime = Conf::DETECT_MIME_TRUE;                             // 是否进行类型检测[is auto detecte media file mime type, default is true]
16
-    public $dir;                                    // 路径[media file dir, magic vars and custom vars are supported]
17
-    public $name;                                   // 上传到服务端的文件名[media file name, magic vars and custom vars are supported]
18
-    public $sizeLimit;                              // 文件大小限制[upload size limited, in bytes]
19
-    public $mimeLimit;                              // 文件类型限制[upload mime type limited]
20
-    public $callbackUrl;                            // 回调URL [callback urls, ip address is recommended]
21
-    public $callbackHost;                           // 回调时Host [callback host]
22
-    public $callbackBody;                           // 回调时Body [callback body, magic vars and custom vars are supported]
23
-    public $callbackBodyType;                       // 回调时Body类型 [callback body type, default is 'application/x-www-form-urlencoded; charset=utf-8']
24
-    public $returnUrl;                              // 上传完成之后,303跳转的Url [return url, when return code is 303]
25
-    public $returnBody;                             // 上传完成返回体 [return body, magic vars and custom vars are supported]
26
-    public $mediaEncode;                            // 上传音视频时,可以指定转码策略[media encode policy after upload task has been completed. it's json string]
15
+    public $detectMime = Conf::DETECT_MIME_TRUE; // 是否进行类型检测[is auto detecte media file mime type, default is true]
16
+    public $dir; // 路径[media file dir, magic vars and custom vars are supported]
17
+    public $name; // 上传到服务端的文件名[media file name, magic vars and custom vars are supported]
18
+    public $sizeLimit; // 文件大小限制[upload size limited, in bytes]
19
+    public $mimeLimit; // 文件类型限制[upload mime type limited]
20
+    public $callbackUrl; // 回调URL [callback urls, ip address is recommended]
21
+    public $callbackHost; // 回调时Host [callback host]
22
+    public $callbackBody; // 回调时Body [callback body, magic vars and custom vars are supported]
23
+    public $callbackBodyType; // 回调时Body类型 [callback body type, default is 'application/x-www-form-urlencoded; charset=utf-8']
24
+    public $returnUrl; // 上传完成之后,303跳转的Url [return url, when return code is 303]
25
+    public $returnBody; // 上传完成返回体 [return body, magic vars and custom vars are supported]
26
+    public $mediaEncode; // 上传音视频时,可以指定转码策略[media encode policy after upload task has been completed. it's json string]
27 27
 
28 28
     public function __construct($option)
29 29
     {
Please login to merge, or discard this patch.
sdk/Utils/ManageOption.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,8 +5,8 @@
 block discarded – undo
5 5
 final class ManageOption extends ResourceInfo
6 6
 {
7 7
 	/*以下属性是”获取资源列表"方法所需的属性。即listFiles()、listDirs()方法中的参数 */
8
-	private $currentPage;                            //当前页号
9
-	private $pageSize;                               //每页的大小
8
+	private $currentPage; //当前页号
9
+	private $pageSize; //每页的大小
10 10
 	/* 以下属性是"扫描黄图和广告图"方法所需的属性。即scanPorn()和scanAdvertising方法中的参数 */
11 11
 	private $filesArray;
12 12
 	private $urlsArray;
Please login to merge, or discard this patch.
sdk/Utils/ResourceInfo.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -5,9 +5,9 @@  discard block
 block discarded – undo
5 5
 class ResourceInfo
6 6
 {
7 7
 	/* 以下属性是资源ID所需的属性*/
8
-	protected $namespace;                              //空间名,必须
9
-	protected $dir;                                    //路径
10
-	protected $name;                                   //文件名信息
8
+	protected $namespace; //空间名,必须
9
+	protected $dir; //路径
10
+	protected $name; //文件名信息
11 11
 	/* 以下属性是资源ID所需的属性*/
12 12
 	/**
13 13
 	 * ResourceOption的构造函数
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	/**对URL中文进行编码*/
58 58
 	protected function urlencode_ch($str)
59 59
 	{
60
-		return preg_replace_callback('/[^\0-\127]+/', function ($match) {
60
+		return preg_replace_callback('/[^\0-\127]+/', function($match) {
61 61
 			return urlencode($match[0]);
62 62
 		}, $str);
63 63
 	}
Please login to merge, or discard this patch.
Braces   +25 added lines, -14 removed lines patch added patch discarded remove patch
@@ -22,10 +22,14 @@  discard block
 block discarded – undo
22 22
 	 * 返回格式{$isValid, $message}*/
23 23
 	public function checkResourceInfo($dirState = false, $nameState = false)
24 24
 	{
25
-		if (empty($this->namespace))
26
-			return array(false, "namespace is empty.[{$this->toString()}]"); // 判断是否设置空间名
27
-		else
28
-			return $this->checkFileInfo($dirState, $nameState); // 判断dir和name的合法性
25
+		if (empty($this->namespace)) {
26
+					return array(false, "namespace is empty.[{$this->toString()}]");
27
+		}
28
+		// 判断是否设置空间名
29
+		else {
30
+					return $this->checkFileInfo($dirState, $nameState);
31
+		}
32
+		// 判断dir和name的合法性
29 33
 	}
30 34
 	/**检测文件信息是否合法。$dirState表示是否检测dir,$nameState表示是否检测filename<p>
31 35
 	 * 返回格式{$isValid, $message}*/
@@ -35,10 +39,14 @@  discard block
 block discarded – undo
35 39
 			return array(false, "file's name is empty.[{$this->toString()}]"); // 1:若需要进行文件名name检测,则判断文件名是否为空
36 40
 		}
37 41
 		if ($dirState) {
38
-			if (empty($this->dir))
39
-				$this->dir = '/'; // 2:判断路径是否为空,若为空,则默认为根目录'/'
40
-			else if (strpos($this->dir, '/') !== 0)
41
-				$this->dir = '/' . $this->dir; // 3:判断路径是否以'/'开头,若不是,则添加'/'
42
+			if (empty($this->dir)) {
43
+							$this->dir = '/';
44
+			}
45
+			// 2:判断路径是否为空,若为空,则默认为根目录'/'
46
+			else if (strpos($this->dir, '/') !== 0) {
47
+							$this->dir = '/' . $this->dir;
48
+			}
49
+			// 3:判断路径是否以'/'开头,若不是,则添加'/'
42 50
 		}
43 51
 		return array(true, null);
44 52
 	}
@@ -46,12 +54,15 @@  discard block
 block discarded – undo
46 54
 	public function buildResourceId()
47 55
 	{
48 56
 		$jsonData = array();
49
-		if (!empty($this->namespace))
50
-			array_push($jsonData, urldecode($this->namespace));
51
-		if (!empty($this->dir))
52
-			array_push($jsonData, urldecode($this->dir));
53
-		if (!empty($this->name))
54
-			array_push($jsonData, urldecode($this->name));
57
+		if (!empty($this->namespace)) {
58
+					array_push($jsonData, urldecode($this->namespace));
59
+		}
60
+		if (!empty($this->dir)) {
61
+					array_push($jsonData, urldecode($this->dir));
62
+		}
63
+		if (!empty($this->name)) {
64
+					array_push($jsonData, urldecode($this->name));
65
+		}
55 66
 		return EncodeUtils::encodeWithURLSafeBase64(json_encode($jsonData, true));
56 67
 	}
57 68
 	/**对URL中文进行编码*/
Please login to merge, or discard this patch.
sdk/AlibabaImage.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	private $namespace;
20 20
 	private $type; // "TOP"和"CLOUD"两种模式
21 21
 
22
-	static $RUN_LEVEL = Conf::RUN_LEVEL_RELEASE;	//设置SDK运行级别
22
+	static $RUN_LEVEL = Conf::RUN_LEVEL_RELEASE; //设置SDK运行级别
23 23
 
24 24
 	/**
25 25
 	 * 构造函数
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	/**
107 107
 	 * 完成分片上传任务。需要指定UploadOption中整个文件的md5值
108 108
 	 */
109
-	public function multipartComplete(UploadPolicy $uploadPolicy,  UploadOption $uploadOption)
109
+	public function multipartComplete(UploadPolicy $uploadPolicy, UploadOption $uploadOption)
110 110
 	{
111 111
 		return $this->upload_client->multipartComplete($uploadPolicy, $uploadOption);
112 112
 	}
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	/**
115 115
 	 * 取消分片上传任务。需要保证UploadOption中有分片任务的uploadId和id
116 116
 	 */
117
-	public function multipartCancel(UploadPolicy $uploadPolicy,  UploadOption $uploadOption)
117
+	public function multipartCancel(UploadPolicy $uploadPolicy, UploadOption $uploadOption)
118 118
 	{
119 119
 		return $this->upload_client->multipartCancel($uploadPolicy, $uploadOption);
120 120
 	}
Please login to merge, or discard this patch.
sdk/Conf/Conf.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -3,39 +3,39 @@
 block discarded – undo
3 3
 
4 4
 class Conf
5 5
 {
6
-    const CHARSET = "UTF-8";
7
-    const SDK_VERSION = '2.0.3';
6
+	const CHARSET = "UTF-8";
7
+	const SDK_VERSION = '2.0.3';
8 8
 
9
-    const UPLOAD_HOST_MEDIA = "https://upload.media.aliyun.com";        //文件上传的地址
10
-    const MANAGE_HOST_MEDIA = "https://rs.media.aliyun.com";            //服务管理的地址
11
-    const MANAGE_API_VERSION = "3.0";        //资源管理接口版本
12
-    const SCAN_PORN_VERSION = "3.1";        //黄图扫描接口版本
13
-    const MEDIA_ENCODE_VERSION = "3.0";        //媒体转码接口版本
9
+	const UPLOAD_HOST_MEDIA = "https://upload.media.aliyun.com";        //文件上传的地址
10
+	const MANAGE_HOST_MEDIA = "https://rs.media.aliyun.com";            //服务管理的地址
11
+	const MANAGE_API_VERSION = "3.0";        //资源管理接口版本
12
+	const SCAN_PORN_VERSION = "3.1";        //黄图扫描接口版本
13
+	const MEDIA_ENCODE_VERSION = "3.0";        //媒体转码接口版本
14 14
 
15
-    const UPLOAD_API_UPLOAD = "/api/proxy/upload";
16
-    const UPLOAD_API_BLOCK_INIT = "/api/proxy/blockInit";
17
-    const UPLOAD_API_BLOCK_UPLOAD = "/api/proxy/blockUpload";
18
-    const UPLOAD_API_BLOCK_COMPLETE = "/api/proxy/blockComplete";
19
-    const UPLOAD_API_BLOCK_CANCEL = "/api/proxy/blockCancel";
15
+	const UPLOAD_API_UPLOAD = "/api/proxy/upload";
16
+	const UPLOAD_API_BLOCK_INIT = "/api/proxy/blockInit";
17
+	const UPLOAD_API_BLOCK_UPLOAD = "/api/proxy/blockUpload";
18
+	const UPLOAD_API_BLOCK_COMPLETE = "/api/proxy/blockComplete";
19
+	const UPLOAD_API_BLOCK_CANCEL = "/api/proxy/blockCancel";
20 20
 
21
-    const TYPE_TOP = "TOP";
22
-    const TYPE_CLOUD = "CLOUD";
21
+	const TYPE_TOP = "TOP";
22
+	const TYPE_CLOUD = "CLOUD";
23 23
 
24
-    const DETECT_MIME_TRUE = 1;            //检测MimeType
25
-    const DETECT_MIME_NONE = 0;            //不检测MimeType
26
-    const INSERT_ONLY_TRUE = 1;            //文件上传不可覆盖
27
-    const INSERT_ONLY_NONE = 0;            //文件上传可覆盖
24
+	const DETECT_MIME_TRUE = 1;            //检测MimeType
25
+	const DETECT_MIME_NONE = 0;            //不检测MimeType
26
+	const INSERT_ONLY_TRUE = 1;            //文件上传不可覆盖
27
+	const INSERT_ONLY_NONE = 0;            //文件上传可覆盖
28 28
 
29
-    const MIN_OBJ_SIZE = 102400;        //1024*100;
30
-    const HTTP_TIMEOUT = 30;            //http的超时时间:30s
31
-    const HTTP_RETRY = 1;                //http失败后重试:1
29
+	const MIN_OBJ_SIZE = 102400;        //1024*100;
30
+	const HTTP_TIMEOUT = 30;            //http的超时时间:30s
31
+	const HTTP_RETRY = 1;                //http失败后重试:1
32 32
 
33
-    const BLOCK_MIN_SIZE = 102400;        //文件分片最小值:1024*100; 100K
34
-    const BLOCK_DEFF_SIZE = 2097152;    //文件分片默认值:1024*1024*2; 2M
35
-    const BLOCK_MAX_SIZE = 10485760;    //文件分片最大值:1024*1024*10; 10M
33
+	const BLOCK_MIN_SIZE = 102400;        //文件分片最小值:1024*100; 100K
34
+	const BLOCK_DEFF_SIZE = 2097152;    //文件分片默认值:1024*1024*2; 2M
35
+	const BLOCK_MAX_SIZE = 10485760;    //文件分片最大值:1024*1024*10; 10M
36 36
 
37
-    const CURL_ERR_LOG = "curl_error.log";    //curl请求时的错误日志信息
37
+	const CURL_ERR_LOG = "curl_error.log";    //curl请求时的错误日志信息
38 38
 
39
-    const RUN_LEVEL_RELEASE = 1;        //release级别
40
-    const RUN_LEVEL_DEBUG = 2;            //debug级别
39
+	const RUN_LEVEL_RELEASE = 1;        //release级别
40
+	const RUN_LEVEL_DEBUG = 2;            //debug级别
41 41
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -6,11 +6,11 @@  discard block
 block discarded – undo
6 6
     const CHARSET = "UTF-8";
7 7
     const SDK_VERSION = '2.0.3';
8 8
 
9
-    const UPLOAD_HOST_MEDIA = "https://upload.media.aliyun.com";        //文件上传的地址
10
-    const MANAGE_HOST_MEDIA = "https://rs.media.aliyun.com";            //服务管理的地址
11
-    const MANAGE_API_VERSION = "3.0";        //资源管理接口版本
12
-    const SCAN_PORN_VERSION = "3.1";        //黄图扫描接口版本
13
-    const MEDIA_ENCODE_VERSION = "3.0";        //媒体转码接口版本
9
+    const UPLOAD_HOST_MEDIA = "https://upload.media.aliyun.com"; //文件上传的地址
10
+    const MANAGE_HOST_MEDIA = "https://rs.media.aliyun.com"; //服务管理的地址
11
+    const MANAGE_API_VERSION = "3.0"; //资源管理接口版本
12
+    const SCAN_PORN_VERSION = "3.1"; //黄图扫描接口版本
13
+    const MEDIA_ENCODE_VERSION = "3.0"; //媒体转码接口版本
14 14
 
15 15
     const UPLOAD_API_UPLOAD = "/api/proxy/upload";
16 16
     const UPLOAD_API_BLOCK_INIT = "/api/proxy/blockInit";
@@ -21,21 +21,21 @@  discard block
 block discarded – undo
21 21
     const TYPE_TOP = "TOP";
22 22
     const TYPE_CLOUD = "CLOUD";
23 23
 
24
-    const DETECT_MIME_TRUE = 1;            //检测MimeType
25
-    const DETECT_MIME_NONE = 0;            //不检测MimeType
26
-    const INSERT_ONLY_TRUE = 1;            //文件上传不可覆盖
27
-    const INSERT_ONLY_NONE = 0;            //文件上传可覆盖
24
+    const DETECT_MIME_TRUE = 1; //检测MimeType
25
+    const DETECT_MIME_NONE = 0; //不检测MimeType
26
+    const INSERT_ONLY_TRUE = 1; //文件上传不可覆盖
27
+    const INSERT_ONLY_NONE = 0; //文件上传可覆盖
28 28
 
29
-    const MIN_OBJ_SIZE = 102400;        //1024*100;
30
-    const HTTP_TIMEOUT = 30;            //http的超时时间:30s
31
-    const HTTP_RETRY = 1;                //http失败后重试:1
29
+    const MIN_OBJ_SIZE = 102400; //1024*100;
30
+    const HTTP_TIMEOUT = 30; //http的超时时间:30s
31
+    const HTTP_RETRY = 1; //http失败后重试:1
32 32
 
33
-    const BLOCK_MIN_SIZE = 102400;        //文件分片最小值:1024*100; 100K
34
-    const BLOCK_DEFF_SIZE = 2097152;    //文件分片默认值:1024*1024*2; 2M
35
-    const BLOCK_MAX_SIZE = 10485760;    //文件分片最大值:1024*1024*10; 10M
33
+    const BLOCK_MIN_SIZE = 102400; //文件分片最小值:1024*100; 100K
34
+    const BLOCK_DEFF_SIZE = 2097152; //文件分片默认值:1024*1024*2; 2M
35
+    const BLOCK_MAX_SIZE = 10485760; //文件分片最大值:1024*1024*10; 10M
36 36
 
37
-    const CURL_ERR_LOG = "curl_error.log";    //curl请求时的错误日志信息
37
+    const CURL_ERR_LOG = "curl_error.log"; //curl请求时的错误日志信息
38 38
 
39
-    const RUN_LEVEL_RELEASE = 1;        //release级别
40
-    const RUN_LEVEL_DEBUG = 2;            //debug级别
39
+    const RUN_LEVEL_RELEASE = 1; //release级别
40
+    const RUN_LEVEL_DEBUG = 2; //debug级别
41 41
 }
Please login to merge, or discard this patch.