@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | return $req->upload($path, $stream, $params); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - if(! $useBlock) { |
|
| 31 | + if (!$useBlock) { |
|
| 32 | 32 | $req = new Rest($this->config); |
| 33 | 33 | return $req->request('PUT', $path) |
| 34 | 34 | ->withHeaders($params) |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | $headers = array(); |
| 54 | 54 | if (is_array($params)) { |
| 55 | 55 | foreach ($params as $key => $val) { |
| 56 | - $headers['X-Upyun-Meta-' . $key] = $val; |
|
| 56 | + $headers['X-Upyun-Meta-'.$key] = $val; |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | $res = $req->request('PUT', $path) |
@@ -103,10 +103,10 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | private function needUseBlock($fileSize) { |
| 106 | - if($this->config->uploadType === 'BLOCK') { |
|
| 106 | + if ($this->config->uploadType === 'BLOCK') { |
|
| 107 | 107 | return true; |
| 108 | - } else if($this->config->uploadType === 'AUTO' && |
|
| 109 | - $fileSize >= $this->config->sizeBoundary ) { |
|
| 108 | + } else if ($this->config->uploadType === 'AUTO' && |
|
| 109 | + $fileSize >= $this->config->sizeBoundary) { |
|
| 110 | 110 | return true; |
| 111 | 111 | } else { |
| 112 | 112 | return false; |
@@ -10,15 +10,15 @@ discard block |
||
| 10 | 10 | /** |
| 11 | 11 | * 获取分块上传接口的签名 |
| 12 | 12 | */ |
| 13 | - const SIGN_MULTIPART = 1; |
|
| 13 | + const SIGN_MULTIPART = 1; |
|
| 14 | 14 | /** |
| 15 | 15 | * 生成视频处理接口的签名 |
| 16 | 16 | */ |
| 17 | - const SIGN_VIDEO = 2; |
|
| 17 | + const SIGN_VIDEO = 2; |
|
| 18 | 18 | /** |
| 19 | 19 | * 生成视频处理接口的签名(不需要操作员时使用) |
| 20 | 20 | */ |
| 21 | - const SIGN_VIDEO_NO_OPERATOR = 3; |
|
| 21 | + const SIGN_VIDEO_NO_OPERATOR = 3; |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * 获取 RESET API 请求需要的签名头 |
@@ -32,14 +32,14 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | public static function getRestApiSignHeader($bucketConfig, $method, $remotePath, $contentLength) { |
| 34 | 34 | $gmtDate = gmdate('D, d M Y H:i:s \G\M\T'); |
| 35 | - $path = '/' . $bucketConfig->bucketName . '/' . ltrim($remotePath, '/'); |
|
| 35 | + $path = '/'.$bucketConfig->bucketName.'/'.ltrim($remotePath, '/'); |
|
| 36 | 36 | |
| 37 | 37 | $sign = md5("$method&$path&$gmtDate&$contentLength&{$bucketConfig->operatorPassword}"); |
| 38 | 38 | |
| 39 | 39 | $headers = array( |
| 40 | 40 | 'Authorization' => "UpYun {$bucketConfig->operatorName}:$sign", |
| 41 | 41 | 'Date' => $gmtDate, |
| 42 | - 'User-agent' => 'Php-Sdk/' . $bucketConfig->getVersion() . ' (rest api)' |
|
| 42 | + 'User-agent' => 'Php-Sdk/'.$bucketConfig->getVersion().' (rest api)' |
|
| 43 | 43 | ); |
| 44 | 44 | return $headers; |
| 45 | 45 | } |
@@ -58,21 +58,21 @@ discard block |
||
| 58 | 58 | return array( |
| 59 | 59 | 'Authorization' => "UpYun {$bucketConfig->bucketName}:{$bucketConfig->operatorName}:$sign", |
| 60 | 60 | 'Date' => $gmtDate, |
| 61 | - 'User-agent' => 'Php-Sdk/' . $bucketConfig->getVersion() . ' (purge api)' |
|
| 61 | + 'User-agent' => 'Php-Sdk/'.$bucketConfig->getVersion().' (purge api)' |
|
| 62 | 62 | ); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | public static function getFormSignature(Config $bucketConfig, $data) { |
| 66 | 66 | $data['bucket'] = $bucketConfig->bucketName; |
| 67 | 67 | $policy = Util::base64Json($data); |
| 68 | - $signature = md5($policy . '&' . $bucketConfig->getFormApiKey()); |
|
| 68 | + $signature = md5($policy.'&'.$bucketConfig->getFormApiKey()); |
|
| 69 | 69 | return array( |
| 70 | 70 | 'policy' => $policy, |
| 71 | 71 | 'signature' => $signature |
| 72 | 72 | ); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - public static function getSignature( Config $bucketConfig, $data, $type, $tokenSecret = '') { |
|
| 75 | + public static function getSignature(Config $bucketConfig, $data, $type, $tokenSecret = '') { |
|
| 76 | 76 | if (is_array($data)) { |
| 77 | 77 | ksort($data); |
| 78 | 78 | $string = ''; |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | $string .= $tokenSecret ? $tokenSecret : $bucketConfig->getFormApiKey(); |
| 88 | 88 | break; |
| 89 | 89 | case self::SIGN_VIDEO: |
| 90 | - $string = $bucketConfig->operatorName . $string . $bucketConfig->operatorPassword; |
|
| 90 | + $string = $bucketConfig->operatorName.$string.$bucketConfig->operatorPassword; |
|
| 91 | 91 | break; |
| 92 | 92 | case self::SIGN_VIDEO_NO_OPERATOR: |
| 93 | 93 | break; |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | $postParams |
| 33 | 33 | ); |
| 34 | 34 | |
| 35 | - if($response->status_code !== 200) { |
|
| 35 | + if ($response->status_code !== 200) { |
|
| 36 | 36 | $body = json_decode($response->body, true); |
| 37 | 37 | throw new \Exception(sprintf('%s, with x-request-id=%s', $body['msg'], $body['id']), $body['code']); |
| 38 | 38 | } |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | if (count($taskIds) <= $limit) { |
| 49 | 49 | $taskIds = implode(',', $taskIds); |
| 50 | 50 | } else { |
| 51 | - throw new \Exception('can not query more than ' . $limit . ' tasks at one time!'); |
|
| 51 | + throw new \Exception('can not query more than '.$limit.' tasks at one time!'); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | $query['task_ids'] = $taskIds; |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $query |
| 66 | 66 | ); |
| 67 | 67 | |
| 68 | - if($response->status_code !== 200) { |
|
| 68 | + if ($response->status_code !== 200) { |
|
| 69 | 69 | $body = json_decode($response->body, true); |
| 70 | 70 | throw new \Exception(sprintf('%s, with x-request-id=%s', $body['msg'], $body['id']), $body['code']); |
| 71 | 71 | } |