@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | use GuzzleHttp\Psr7; |
7 | 7 | use Upyun\Upyun; |
8 | 8 | |
9 | -class MultiTest extends \PHPUnit_Framework_TestCase{ |
|
9 | +class MultiTest extends \PHPUnit_Framework_TestCase { |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * @var Multi; |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | } |
21 | 21 | |
22 | 22 | public function testUpload() { |
23 | - $filePath = __DIR__ . '/../assets/sample.jpeg'; |
|
23 | + $filePath = __DIR__.'/../assets/sample.jpeg'; |
|
24 | 24 | $stream = Psr7\stream_for(fopen($filePath, 'rb')); |
25 | 25 | $r = $this->multiPart->upload('test-sample.jpeg', $stream, md5_file($filePath)); |
26 | 26 | $this->assertEquals($r->getStatusCode(), 200); |
@@ -111,7 +111,7 @@ |
||
111 | 111 | throw new \Exception('form api key is empty.'); |
112 | 112 | } |
113 | 113 | |
114 | - return $this->formApiKey; |
|
114 | + return $this->formApiKey; |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | public function setFormApiKey($key) { |
@@ -87,17 +87,17 @@ discard block |
||
87 | 87 | /** |
88 | 88 | * 分块上传接口请求地址 |
89 | 89 | */ |
90 | - const ED_FORM = 'm0.api.upyun.com'; |
|
90 | + const ED_FORM = 'm0.api.upyun.com'; |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * 异步云处理接口地址 |
94 | 94 | */ |
95 | - const ED_VIDEO = 'p0.api.upyun.com'; |
|
95 | + const ED_VIDEO = 'p0.api.upyun.com'; |
|
96 | 96 | |
97 | 97 | /** |
98 | 98 | * 刷新接口地址 |
99 | 99 | */ |
100 | - const ED_PURGE = 'http://purge.upyun.com/purge/'; |
|
100 | + const ED_PURGE = 'http://purge.upyun.com/purge/'; |
|
101 | 101 | |
102 | 102 | public function __construct($bucketName, $operatorName, $operatorPassword) { |
103 | 103 | $this->bucketName = $bucketName; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | public function getFormApiKey() { |
115 | - if (! $this->formApiKey) { |
|
115 | + if (!$this->formApiKey) { |
|
116 | 116 | throw new \Exception('form api key is empty.'); |
117 | 117 | } |
118 | 118 |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $method = 'POST'; |
36 | 36 | $signedHeaders = Signature::getHeaderSign($this->config, $method, $path); |
37 | 37 | |
38 | - $response = $client->request($method, $this->url . $path, [ |
|
38 | + $response = $client->request($method, $this->url.$path, [ |
|
39 | 39 | 'headers' => $signedHeaders, |
40 | 40 | 'form_params' => $params |
41 | 41 | ]); |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | 'service' => $this->config->bucketName, |
55 | 55 | 'task_ids' => implode(',', $taskIds) |
56 | 56 | ); |
57 | - $path = $path . '?' . http_build_query($params); |
|
57 | + $path = $path.'?'.http_build_query($params); |
|
58 | 58 | |
59 | 59 | $method = 'GET'; |
60 | - $url = $this->url . $path; |
|
60 | + $url = $this->url.$path; |
|
61 | 61 | $signedHeaders = Signature::getHeaderSign($this->config, $method, $path); |
62 | 62 | $response = $client->request($method, $url, [ |
63 | 63 | 'headers' => $signedHeaders |
@@ -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 | * 获取 Header 签名需要的请求头 |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | $headers = array( |
40 | 40 | 'Authorization' => $sign, |
41 | 41 | 'Date' => $gmtDate, |
42 | - 'User-agent' => 'Php-Sdk/' . $bucketConfig->getVersion() |
|
42 | + 'User-agent' => 'Php-Sdk/'.$bucketConfig->getVersion() |
|
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 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $data[] = $contentMd5; |
91 | 91 | } |
92 | 92 | $signature = base64_encode(hash_hmac('sha1', implode('&', $data), $bucketConfig->operatorPassword, true)); |
93 | - return 'UPYUN ' . $bucketConfig->operatorName . ':' . $signature; |
|
93 | + return 'UPYUN '.$bucketConfig->operatorName.':'.$signature; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | public static function getSignature(Config $bucketConfig, $data, $type, $tokenSecret = '') { |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $string .= $tokenSecret ? $tokenSecret : $bucketConfig->getFormApiKey(); |
109 | 109 | break; |
110 | 110 | case self::SIGN_VIDEO: |
111 | - $string = $bucketConfig->operatorName . $string . $bucketConfig->operatorPassword; |
|
111 | + $string = $bucketConfig->operatorName.$string.$bucketConfig->operatorPassword; |
|
112 | 112 | break; |
113 | 113 | case self::SIGN_VIDEO_NO_OPERATOR: |
114 | 114 | break; |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | use Upyun\Util; |
7 | 7 | use GuzzleHttp\Client; |
8 | 8 | |
9 | -class Form extends Rest{ |
|
9 | +class Form extends Rest { |
|
10 | 10 | |
11 | 11 | public function upload($path, $stream, $params) { |
12 | 12 | $params['save-key'] = $path; |
@@ -17,12 +17,12 @@ discard block |
||
17 | 17 | |
18 | 18 | $policy = Util::base64Json($params); |
19 | 19 | $method = 'POST'; |
20 | - $signature = Signature::getBodySignature($this->config, $method, '/' . $params['bucket'], null, $policy); |
|
20 | + $signature = Signature::getBodySignature($this->config, $method, '/'.$params['bucket'], null, $policy); |
|
21 | 21 | $client = new Client([ |
22 | 22 | 'timeout' => $this->config->timeout, |
23 | 23 | ]); |
24 | 24 | |
25 | - $url = ($this->config->useSsl ? 'https://' : 'http://') . $this->endpoint; |
|
25 | + $url = ($this->config->useSsl ? 'https://' : 'http://').$this->endpoint; |
|
26 | 26 | |
27 | 27 | $response = $client->request($method, $url, array( |
28 | 28 | 'multipart' => array( |
@@ -3,7 +3,7 @@ |
||
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; |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | use Upyun\Config; |
4 | 4 | use Upyun\Upyun; |
5 | 5 | |
6 | -class UpyunTest extends \PHPUnit_Framework_TestCase{ |
|
6 | +class UpyunTest extends \PHPUnit_Framework_TestCase { |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * @var Upyun |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | $config->setFormApiKey('Mv83tlocuzkmfKKUFbz2s04FzTw='); |
21 | 21 | $config->processNotifyUrl = 'http://localhost:9999'; |
22 | 22 | self::$upyun = new Upyun($config); |
23 | - self::$tempFilePath = __DIR__ . '/assets/test.txt'; |
|
23 | + self::$tempFilePath = __DIR__.'/assets/test.txt'; |
|
24 | 24 | touch(self::$tempFilePath); |
25 | 25 | } |
26 | 26 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | public function testWriteStream() { |
40 | 40 | $filename = 'test.jpeg'; |
41 | - $f = fopen(__DIR__ . '/assets/sample.jpeg', 'rb'); |
|
41 | + $f = fopen(__DIR__.'/assets/sample.jpeg', 'rb'); |
|
42 | 42 | if (!$f) { |
43 | 43 | throw new \Exception('open test file failed!'); |
44 | 44 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | public function testWriteWithAsyncProcess() { |
51 | 51 | $filename = 'test_async.jpeg'; |
52 | 52 | $newFilename = 'test_async.png'; |
53 | - $f = fopen(__DIR__ . '/assets/sample.jpeg', 'rb'); |
|
53 | + $f = fopen(__DIR__.'/assets/sample.jpeg', 'rb'); |
|
54 | 54 | if (!$f) { |
55 | 55 | throw new \Exception('open test file failed!'); |
56 | 56 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | try { |
74 | 74 | $fs->write('test.txt', 'test file content'); |
75 | 75 | } catch (\Exception $e) { |
76 | - return ; |
|
76 | + return; |
|
77 | 77 | } |
78 | 78 | throw new \Exception('should get sign error.'); |
79 | 79 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | try { |
106 | 106 | self::$upyun->read('test-delete.txt'); |
107 | 107 | } catch (\Exception $e) { |
108 | - return ; |
|
108 | + return; |
|
109 | 109 | } |
110 | 110 | throw new \Exception('delete file failed'); |
111 | 111 | } |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | |
190 | 190 | public function testProcess() { |
191 | 191 | $source = 'php-sdk-sample.mp4'; |
192 | - self::$upyun->write($source, fopen(__DIR__ . '/assets/SampleVideo_640x360_1mb.mp4', 'r')); |
|
192 | + self::$upyun->write($source, fopen(__DIR__.'/assets/SampleVideo_640x360_1mb.mp4', 'r')); |
|
193 | 193 | $result = self::$upyun->process($source, array( |
194 | 194 | array('type' => 'video', 'avopts' => '/s/240p(4:3)/as/1/r/30', 'return_info' => true, 'save_as' => '/video/result.mp4') |
195 | 195 | )); |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | |
28 | 28 | public function __construct(Config $config) { |
29 | 29 | $this->config = $config; |
30 | - $this->endpoint = Config::$restApiEndPoint . '/' . $config->bucketName; |
|
30 | + $this->endpoint = Config::$restApiEndPoint.'/'.$config->bucketName; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | public function request($method, $storagePath) { |
34 | 34 | $this->method = strtoupper($method); |
35 | - $this->storagePath = '/' . ltrim($storagePath, '/'); |
|
35 | + $this->storagePath = '/'.ltrim($storagePath, '/'); |
|
36 | 36 | return $this; |
37 | 37 | } |
38 | 38 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | 'timeout' => $this->config->timeout, |
58 | 58 | ]); |
59 | 59 | |
60 | - $url = ($this->config->useSsl ? 'https://' : 'http://') . $this->endpoint . $this->storagePath; |
|
60 | + $url = ($this->config->useSsl ? 'https://' : 'http://').$this->endpoint.$this->storagePath; |
|
61 | 61 | $body = null; |
62 | 62 | if ($this->file && $this->method === 'PUT') { |
63 | 63 | $body = $this->file; |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | public function __construct(Config $config) { |
19 | 19 | $this->config = $config; |
20 | 20 | $this->url = ($this->config->useSsl ? 'https://' : 'http://') . Config::ED_FORM . '/'. |
21 | - $this->config->bucketName; |
|
21 | + $this->config->bucketName; |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | |
105 | 105 | $multipart = []; |
106 | 106 | foreach ($postData as $key => $value) { |
107 | - $multipart[] = ['name' => $key, 'contents' => $value]; |
|
107 | + $multipart[] = ['name' => $key, 'contents' => $value]; |
|
108 | 108 | } |
109 | 109 | $multipart[] = [ |
110 | 110 | 'name' => 'file', |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | |
18 | 18 | public function __construct(Config $config) { |
19 | 19 | $this->config = $config; |
20 | - $this->url = ($this->config->useSsl ? 'https://' : 'http://') . Config::ED_FORM . '/'. |
|
20 | + $this->url = ($this->config->useSsl ? 'https://' : 'http://').Config::ED_FORM.'/'. |
|
21 | 21 | $this->config->bucketName; |
22 | 22 | } |
23 | 23 | |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @throws \Exception |
32 | 32 | */ |
33 | 33 | public function upload($path, $stream, $fileHash, $params = []) { |
34 | - $path = '/' . ltrim($path, '/'); |
|
34 | + $path = '/'.ltrim($path, '/'); |
|
35 | 35 | $initInfo = $this->initRequest($path, $stream, $fileHash, $params); |
36 | 36 | $blockStatus = $initInfo->status; |
37 | 37 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | $multipart[] = [ |
110 | 110 | 'name' => 'file', |
111 | 111 | 'contents' => $fileBlock, |
112 | - 'filename' => 'file', //this value must be file |
|
112 | + 'filename' => 'file', //this value must be file |
|
113 | 113 | 'headers' => ['Content-Type' => 'application/octet-stream'] |
114 | 114 | ]; |
115 | 115 | $postData['file'] = $fileBlock; |