@@ -212,7 +212,8 @@ discard block |
||
| 212 | 212 | |
| 213 | 213 | /** |
| 214 | 214 | * 连接签名方法 |
| 215 | - * @param $method string 请求方式 {GET, POST, PUT, DELETE} |
|
| 215 | + * @param string $method string 请求方式 {GET, POST, PUT, DELETE} |
|
| 216 | + * @param string $date |
|
| 216 | 217 | * @return string 签名字符串 |
| 217 | 218 | */ |
| 218 | 219 | private function sign($method, $uri, $date, $length) |
@@ -229,7 +230,7 @@ discard block |
||
| 229 | 230 | * @param array $headers 请求需要的特殊HTTP HEADERS |
| 230 | 231 | * @param array $body 需要POST发送的数据 |
| 231 | 232 | * @param null $file_handle |
| 232 | - * @return mixed |
|
| 233 | + * @return string |
|
| 233 | 234 | * @throws UpYunAuthorizationException |
| 234 | 235 | * @throws UpYunException |
| 235 | 236 | * @throws UpYunForbiddenException |
@@ -373,7 +374,7 @@ discard block |
||
| 373 | 374 | * |
| 374 | 375 | * @param string $header_string |
| 375 | 376 | * |
| 376 | - * @return mixed |
|
| 377 | + * @return string |
|
| 377 | 378 | */ |
| 378 | 379 | private function _getErrorMessage($header_string) |
| 379 | 380 | { |
@@ -405,6 +406,9 @@ discard block |
||
| 405 | 406 | |
| 406 | 407 | class UpYunAuthorizationException extends UpYunException |
| 407 | 408 | { |
| 409 | + /** |
|
| 410 | + * @param string|null $message |
|
| 411 | + */ |
|
| 408 | 412 | public function __construct($message, $code = 0, Exception $previous = null) |
| 409 | 413 | { |
| 410 | 414 | parent::__construct($message, 401, $previous); |
@@ -413,6 +417,9 @@ discard block |
||
| 413 | 417 | |
| 414 | 418 | class UpYunForbiddenException extends UpYunException |
| 415 | 419 | { |
| 420 | + /** |
|
| 421 | + * @param string|null $message |
|
| 422 | + */ |
|
| 416 | 423 | public function __construct($message, $code = 0, Exception $previous = null) |
| 417 | 424 | { |
| 418 | 425 | parent::__construct($message, 403, $previous); |
@@ -421,6 +428,9 @@ discard block |
||
| 421 | 428 | |
| 422 | 429 | class UpYunNotFoundException extends UpYunException |
| 423 | 430 | { |
| 431 | + /** |
|
| 432 | + * @param string|null $message |
|
| 433 | + */ |
|
| 424 | 434 | public function __construct($message, $code = 0, Exception $previous = null) |
| 425 | 435 | { |
| 426 | 436 | parent::__construct($message, 404, $previous); |
@@ -429,6 +439,9 @@ discard block |
||
| 429 | 439 | |
| 430 | 440 | class UpYunNotAcceptableException extends UpYunException |
| 431 | 441 | { |
| 442 | + /** |
|
| 443 | + * @param string|null $message |
|
| 444 | + */ |
|
| 432 | 445 | public function __construct($message, $code = 0, Exception $previous = null) |
| 433 | 446 | { |
| 434 | 447 | parent::__construct($message, 406, $previous); |
@@ -437,6 +450,9 @@ discard block |
||
| 437 | 450 | |
| 438 | 451 | class UpYunServiceUnavailable extends UpYunException |
| 439 | 452 | { |
| 453 | + /** |
|
| 454 | + * @param string|null $message |
|
| 455 | + */ |
|
| 440 | 456 | public function __construct($message, $code = 0, Exception $previous = null) |
| 441 | 457 | { |
| 442 | 458 | parent::__construct($message, 503, $previous); |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | { |
| 220 | 220 | //$uri = urlencode($uri); |
| 221 | 221 | $sign = "{$method}&{$uri}&{$date}&{$length}&{$this->_password}"; |
| 222 | - return 'UpYun ' . $this->_username . ':' . md5($sign); |
|
| 222 | + return 'UpYun '.$this->_username.':'.md5($sign); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | /** |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | { |
| 380 | 380 | list($status, $stash) = explode("\r\n", $header_string, 2); |
| 381 | 381 | list($v, $code, $message) = explode(" ", $status, 3); |
| 382 | - return $message . " X-Request-Id: " . $this->getXRequestId(); |
|
| 382 | + return $message." X-Request-Id: ".$this->getXRequestId(); |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | private function setXRequestId($header_string) |
@@ -394,12 +394,12 @@ discard block |
||
| 394 | 394 | { |
| 395 | 395 | public function __construct($message, $code, Exception $previous = null) |
| 396 | 396 | { |
| 397 | - parent::__construct($message, $code); // For PHP 5.2.x |
|
| 397 | + parent::__construct($message, $code); // For PHP 5.2.x |
|
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | public function __toString() |
| 401 | 401 | { |
| 402 | - return __CLASS__ . ": [{$this->code}]: {$this->message}\n"; |
|
| 402 | + return __CLASS__.": [{$this->code}]: {$this->message}\n"; |
|
| 403 | 403 | } |
| 404 | 404 | } |
| 405 | 405 | |
@@ -1,17 +1,17 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | require_once(dirname(__DIR__).'/vendor/autoload.php'); |
| 3 | -$config = array( |
|
| 3 | +$config = array( |
|
| 4 | 4 | 'user_name' => 'tester', |
| 5 | 5 | 'pwd' => 'grjxv2mxELR3', |
| 6 | 6 | 'bucket' => 'sdkimg', |
| 7 | - 'picture_path' => dirname(__FILE__) . '/assets/sample.jpeg' |
|
| 7 | + 'picture_path' => dirname(__FILE__).'/assets/sample.jpeg' |
|
| 8 | 8 | ); |
| 9 | 9 | $upyun = new UpYun($config['bucket'], $config['user_name'], $config['pwd']); |
| 10 | 10 | |
| 11 | 11 | try { |
| 12 | 12 | echo "=========直接上传文件\r\n"; |
| 13 | 13 | $fh = fopen(__DIR__.'/sample.jpeg', 'rb'); |
| 14 | - $rsp = $upyun->writeFile('/demo/sample_normal.jpeg', $fh, True); // 上传图片,自动创建目录 |
|
| 14 | + $rsp = $upyun->writeFile('/demo/sample_normal.jpeg', $fh, True); // 上传图片,自动创建目录 |
|
| 15 | 15 | fclose($fh); |
| 16 | 16 | var_dump($rsp); |
| 17 | 17 | echo "=========DONE\n\r\n"; |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | UpYun::CONTENT_MD5 => md5(file_get_contents(__DIR__.'/sample.jpeg')) |
| 22 | 22 | ); |
| 23 | 23 | $fh = fopen(__DIR__.'/sample.jpeg', 'rb'); |
| 24 | - $rsp = $upyun->writeFile('/demo/sample_md5.jpeg', $fh, True, $opts); // 上传图片,自动创建目录 |
|
| 24 | + $rsp = $upyun->writeFile('/demo/sample_md5.jpeg', $fh, True, $opts); // 上传图片,自动创建目录 |
|
| 25 | 25 | fclose($fh); |
| 26 | 26 | var_dump($rsp); |
| 27 | 27 | echo "=========DONE\r\n\r\n"; |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | UpYun::X_GMKERL_UNSHARP => True // 是否进行锐化处理 |
| 35 | 35 | ); |
| 36 | 36 | $fh = fopen(__DIR__.'/sample.jpeg', 'rb'); |
| 37 | - $rsp = $upyun->writeFile('/demo/sample_thumb_1.jpeg', $fh, True, $opts); // 上传图片,自动创建目录 |
|
| 37 | + $rsp = $upyun->writeFile('/demo/sample_thumb_1.jpeg', $fh, True, $opts); // 上传图片,自动创建目录 |
|
| 38 | 38 | fclose($fh); |
| 39 | 39 | var_dump($rsp); |
| 40 | 40 | echo "=========DONE\r\n\r\n"; |
@@ -44,12 +44,12 @@ discard block |
||
| 44 | 44 | UpYun::X_GMKERL_THUMBNAIL => 'thumbtype' |
| 45 | 45 | ); |
| 46 | 46 | $fh = fopen(__DIR__.'/sample.jpeg', 'rb'); |
| 47 | - $rsp = $upyun->writeFile('/demo/sample_thumb_2.jpeg', $fh, True, $opts); // 上传图片,自动创建目录 |
|
| 47 | + $rsp = $upyun->writeFile('/demo/sample_thumb_2.jpeg', $fh, True, $opts); // 上传图片,自动创建目录 |
|
| 48 | 48 | fclose($fh); |
| 49 | 49 | var_dump($rsp); |
| 50 | 50 | echo "=========DONE\r\n\r\n"; |
| 51 | 51 | } |
| 52 | -catch(Exception $e) { |
|
| 52 | +catch (Exception $e) { |
|
| 53 | 53 | echo $e->getCode(); |
| 54 | 54 | echo $e->getMessage(); |
| 55 | 55 | } |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | require_once(dirname(__DIR__).'/vendor/autoload.php'); |
| 3 | -$config = array( |
|
| 3 | +$config = array( |
|
| 4 | 4 | 'user_name' => 'tester', |
| 5 | 5 | 'pwd' => 'grjxv2mxELR3', |
| 6 | 6 | 'bucket' => 'sdkimg', |
| 7 | - 'picture_path' => dirname(__FILE__) . '/assets/sample.jpeg' |
|
| 7 | + 'picture_path' => dirname(__FILE__).'/assets/sample.jpeg' |
|
| 8 | 8 | ); |
| 9 | 9 | $upyun = new UpYun($config['bucket'], $config['user_name'], $config['pwd']); |
| 10 | 10 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | var_dump($list); |
| 15 | 15 | echo "=========DONE\r\n\r\n"; |
| 16 | 16 | } |
| 17 | -catch(Exception $e) { |
|
| 17 | +catch (Exception $e) { |
|
| 18 | 18 | echo $e->getCode(); |
| 19 | 19 | echo $e->getMessage(); |
| 20 | 20 | } |