@@ -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; |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | use Upyun\Signature; |
| 6 | 6 | use GuzzleHttp\Client; |
| 7 | 7 | |
| 8 | -class Form extends Rest{ |
|
| 8 | +class Form extends Rest { |
|
| 9 | 9 | |
| 10 | 10 | public function upload($path, $stream, $params) { |
| 11 | 11 | $params['save-key'] = $path; |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | 'timeout' => $this->config->timeout, |
| 22 | 22 | ]); |
| 23 | 23 | |
| 24 | - $url = ($this->config->useSsl ? 'https://' : 'http://') . $this->endpoint; |
|
| 24 | + $url = ($this->config->useSsl ? 'https://' : 'http://').$this->endpoint; |
|
| 25 | 25 | |
| 26 | 26 | $response = $client->request('POST', $url, array( |
| 27 | 27 | 'multipart' => array( |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | ), |
| 32 | 32 | array( |
| 33 | 33 | 'name' => 'authorization', |
| 34 | - 'contents' => 'UPYUN ' . $this->config->operatorName . ':' . $signature, |
|
| 34 | + 'contents' => 'UPYUN '.$this->config->operatorName.':'.$signature, |
|
| 35 | 35 | ), |
| 36 | 36 | array( |
| 37 | 37 | 'name' => 'file', |
@@ -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,7 +58,7 @@ 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 | |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | $policy = Util::base64Json($data); |
| 68 | 68 | $signParams = array( |
| 69 | 69 | 'method' => 'POST', |
| 70 | - 'uri' => '/' . $bucketConfig->bucketName, |
|
| 70 | + 'uri' => '/'.$bucketConfig->bucketName, |
|
| 71 | 71 | ); |
| 72 | 72 | if (isset($data['date'])) { |
| 73 | 73 | $signParams['date'] = $data['date']; |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | ); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - public static function getSignature( Config $bucketConfig, $data, $type, $tokenSecret = '') { |
|
| 88 | + public static function getSignature(Config $bucketConfig, $data, $type, $tokenSecret = '') { |
|
| 89 | 89 | if (is_array($data)) { |
| 90 | 90 | ksort($data); |
| 91 | 91 | $string = ''; |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | $string .= $tokenSecret ? $tokenSecret : $bucketConfig->getFormApiKey(); |
| 101 | 101 | break; |
| 102 | 102 | case self::SIGN_VIDEO: |
| 103 | - $string = $bucketConfig->operatorName . $string . $bucketConfig->operatorPassword; |
|
| 103 | + $string = $bucketConfig->operatorName.$string.$bucketConfig->operatorPassword; |
|
| 104 | 104 | break; |
| 105 | 105 | case self::SIGN_VIDEO_NO_OPERATOR: |
| 106 | 106 | break; |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | use Upyun\Signature; |
| 4 | 4 | use Upyun\Config; |
| 5 | 5 | |
| 6 | -class SignatureTest extends \PHPUnit_Framework_TestCase{ |
|
| 6 | +class SignatureTest extends \PHPUnit_Framework_TestCase { |
|
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | 9 | * @var Config; |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | public function testGetSignature() { |
| 18 | 18 | $sign = Signature::getSignature($this->config, array('a' => 'a', 'b' => 'b'), Signature::SIGN_MULTIPART, '123'); |
| 19 | - $this->assertEquals($sign , '2aa0afd612df8fab4b3fded36c396234'); |
|
| 19 | + $this->assertEquals($sign, '2aa0afd612df8fab4b3fded36c396234'); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | public function testGetFormSignature() { |