@@ -31,9 +31,9 @@ |
||
31 | 31 | if (! $useBlock) { |
32 | 32 | $req = new Rest($this->config); |
33 | 33 | return $req->request('PUT', $path) |
34 | - ->withHeaders($params) |
|
35 | - ->withFile($stream) |
|
36 | - ->send(); |
|
34 | + ->withHeaders($params) |
|
35 | + ->withFile($stream) |
|
36 | + ->send(); |
|
37 | 37 | } else { |
38 | 38 | return $this->pointUpload($path, $stream, $params); |
39 | 39 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | return $req->upload($path, $stream, $params); |
32 | 32 | } |
33 | 33 | |
34 | - if (! $useBlock) { |
|
34 | + if (!$useBlock) { |
|
35 | 35 | $req = new Rest($this->config); |
36 | 36 | return $req->request('PUT', $path) |
37 | 37 | ->withHeaders($params) |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | $headers = array(); |
58 | 58 | if (is_array($params)) { |
59 | 59 | foreach ($params as $key => $val) { |
60 | - $headers['X-Upyun-Meta-' . $key] = $val; |
|
60 | + $headers['X-Upyun-Meta-'.$key] = $val; |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | $res = $req->request('PUT', $path) |
@@ -1,15 +1,15 @@ |
||
1 | 1 | <?php |
2 | -require dirname(__DIR__) . '/vendor/autoload.php'; |
|
2 | +require dirname(__DIR__).'/vendor/autoload.php'; |
|
3 | 3 | |
4 | 4 | define('USER_NAME', 'tester'); |
5 | 5 | define('PWD', 'grjxv2mxELR3'); |
6 | 6 | define('BUCKET', 'sdkimg'); |
7 | -define('PIC_PATH', dirname(__FILE__) . '/assets/sample.jpeg'); |
|
7 | +define('PIC_PATH', dirname(__FILE__).'/assets/sample.jpeg'); |
|
8 | 8 | define('PIC_SIZE', filesize(PIC_PATH)); |
9 | 9 | |
10 | 10 | function getFileUrl($path) |
11 | 11 | { |
12 | - return "http://" . BUCKET . ".b0.upaiyun.com/" . ltrim($path, '/'); |
|
12 | + return "http://".BUCKET.".b0.upaiyun.com/".ltrim($path, '/'); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | function getUpyunFileSize($path) |
@@ -23,7 +23,7 @@ |
||
23 | 23 | |
24 | 24 | public function testUpload() |
25 | 25 | { |
26 | - $filePath = __DIR__ . '/../assets/sample.jpeg'; |
|
26 | + $filePath = __DIR__.'/../assets/sample.jpeg'; |
|
27 | 27 | $stream = Psr7\stream_for(fopen($filePath, 'rb')); |
28 | 28 | $r = $this->multiPart->upload('test-sample.jpeg', $stream, md5_file($filePath)); |
29 | 29 | $this->assertEquals($r->getStatusCode(), 200); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | $config->setFormApiKey('Mv83tlocuzkmfKKUFbz2s04FzTw='); |
24 | 24 | $config->processNotifyUrl = 'http://localhost:9999'; |
25 | 25 | self::$upyun = new Upyun($config); |
26 | - self::$tempFilePath = __DIR__ . '/assets/test.txt'; |
|
26 | + self::$tempFilePath = __DIR__.'/assets/test.txt'; |
|
27 | 27 | touch(self::$tempFilePath); |
28 | 28 | } |
29 | 29 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | public function testWriteStream() |
45 | 45 | { |
46 | 46 | $filename = 'test.jpeg'; |
47 | - $f = fopen(__DIR__ . '/assets/sample.jpeg', 'rb'); |
|
47 | + $f = fopen(__DIR__.'/assets/sample.jpeg', 'rb'); |
|
48 | 48 | if (!$f) { |
49 | 49 | throw new \Exception('open test file failed!'); |
50 | 50 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | { |
58 | 58 | $filename = 'test_async.jpeg'; |
59 | 59 | $newFilename = 'test_async.png'; |
60 | - $f = fopen(__DIR__ . '/assets/sample.jpeg', 'rb'); |
|
60 | + $f = fopen(__DIR__.'/assets/sample.jpeg', 'rb'); |
|
61 | 61 | if (!$f) { |
62 | 62 | throw new \Exception('open test file failed!'); |
63 | 63 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | try { |
82 | 82 | $fs->write('test.txt', 'test file content'); |
83 | 83 | } catch (\Exception $e) { |
84 | - return ; |
|
84 | + return; |
|
85 | 85 | } |
86 | 86 | throw new \Exception('should get sign error.'); |
87 | 87 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | try { |
116 | 116 | self::$upyun->read('test-delete.txt'); |
117 | 117 | } catch (\Exception $e) { |
118 | - return ; |
|
118 | + return; |
|
119 | 119 | } |
120 | 120 | throw new \Exception('delete file failed'); |
121 | 121 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | public function testProcess() |
209 | 209 | { |
210 | 210 | $source = 'php-sdk-sample.mp4'; |
211 | - self::$upyun->write($source, fopen(__DIR__ . '/assets/SampleVideo_640x360_1mb.mp4', 'r')); |
|
211 | + self::$upyun->write($source, fopen(__DIR__.'/assets/SampleVideo_640x360_1mb.mp4', 'r')); |
|
212 | 212 | $result = self::$upyun->process($source, array( |
213 | 213 | array('type' => 'video', 'avopts' => '/s/240p(4:3)/as/1/r/30', 'return_info' => true, 'save_as' => '/video/result.mp4') |
214 | 214 | )); |
@@ -72,12 +72,12 @@ |
||
72 | 72 | public static function encodeURI($url) |
73 | 73 | { |
74 | 74 | $unescaped = array( |
75 | - '%2D'=>'-','%5F'=>'_','%2E'=>'.','%21'=>'!', '%7E'=>'~', |
|
75 | + '%2D'=>'-', '%5F'=>'_', '%2E'=>'.', '%21'=>'!', '%7E'=>'~', |
|
76 | 76 | '%2A'=>'*', '%27'=>"'", '%28'=>'(', '%29'=>')' |
77 | 77 | ); |
78 | 78 | $reserved = array( |
79 | - '%3B'=>';','%2C'=>',','%2F'=>'/','%3F'=>'?','%3A'=>':', |
|
80 | - '%40'=>'@','%26'=>'&','%3D'=>'=','%2B'=>'+','%24'=>'$' |
|
79 | + '%3B'=>';', '%2C'=>',', '%2F'=>'/', '%3F'=>'?', '%3A'=>':', |
|
80 | + '%40'=>'@', '%26'=>'&', '%3D'=>'=', '%2B'=>'+', '%24'=>'$' |
|
81 | 81 | ); |
82 | 82 | $score = array( |
83 | 83 | '%23'=>'#' |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | $params = Util::getHeaderParams($response->getHeaders()); |
127 | 127 | |
128 | 128 | |
129 | - if (! isset($params['x-upyun-list-iter'])) { |
|
129 | + if (!isset($params['x-upyun-list-iter'])) { |
|
130 | 130 | if (is_resource($saveHandler)) { |
131 | 131 | Psr7\copy_to_stream($response->getBody(), Psr7\stream_for($saveHandler)); |
132 | 132 | return true; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | */ |
216 | 216 | public function createDir($path) |
217 | 217 | { |
218 | - $path = rtrim($path, '/') . '/'; |
|
218 | + $path = rtrim($path, '/').'/'; |
|
219 | 219 | $req = new Rest($this->config); |
220 | 220 | $res = $req->request('POST', $path) |
221 | 221 | ->withHeader('folder', 'true') |
@@ -245,9 +245,9 @@ discard block |
||
245 | 245 | */ |
246 | 246 | public function usage($path = '/') |
247 | 247 | { |
248 | - $path = rtrim($path, '/') . '/'; |
|
248 | + $path = rtrim($path, '/').'/'; |
|
249 | 249 | $req = new Rest($this->config); |
250 | - $response = $req->request('GET', $path . '?usage') |
|
250 | + $response = $req->request('GET', $path.'?usage') |
|
251 | 251 | ->send(); |
252 | 252 | |
253 | 253 | return $response->getBody()->getContents(); |
@@ -88,17 +88,17 @@ discard block |
||
88 | 88 | /** |
89 | 89 | * 分块上传接口请求地址 |
90 | 90 | */ |
91 | - const ED_FORM = 'm0.api.upyun.com'; |
|
91 | + const ED_FORM = 'm0.api.upyun.com'; |
|
92 | 92 | |
93 | 93 | /** |
94 | 94 | * 异步云处理接口地址 |
95 | 95 | */ |
96 | - const ED_VIDEO = 'p0.api.upyun.com'; |
|
96 | + const ED_VIDEO = 'p0.api.upyun.com'; |
|
97 | 97 | |
98 | 98 | /** |
99 | 99 | * 刷新接口地址 |
100 | 100 | */ |
101 | - const ED_PURGE = 'http://purge.upyun.com/purge/'; |
|
101 | + const ED_PURGE = 'http://purge.upyun.com/purge/'; |
|
102 | 102 | |
103 | 103 | public function __construct($bucketName, $operatorName, $operatorPassword) |
104 | 104 | { |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | |
117 | 117 | public function getFormApiKey() |
118 | 118 | { |
119 | - if (! $this->formApiKey) { |
|
119 | + if (!$this->formApiKey) { |
|
120 | 120 | throw new \Exception('form api key is empty.'); |
121 | 121 | } |
122 | 122 |
@@ -29,13 +29,13 @@ discard block |
||
29 | 29 | public function __construct(Config $config) |
30 | 30 | { |
31 | 31 | $this->config = $config; |
32 | - $this->endpoint = Config::$restApiEndPoint . '/' . $config->bucketName; |
|
32 | + $this->endpoint = Config::$restApiEndPoint.'/'.$config->bucketName; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public function request($method, $storagePath) |
36 | 36 | { |
37 | 37 | $this->method = strtoupper($method); |
38 | - $this->storagePath = '/' . ltrim($storagePath, '/'); |
|
38 | + $this->storagePath = '/'.ltrim($storagePath, '/'); |
|
39 | 39 | return $this; |
40 | 40 | } |
41 | 41 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | 'timeout' => $this->config->timeout, |
63 | 63 | ]); |
64 | 64 | |
65 | - $url = ($this->config->useSsl ? 'https://' : 'http://') . $this->endpoint . $this->storagePath; |
|
65 | + $url = ($this->config->useSsl ? 'https://' : 'http://').$this->endpoint.$this->storagePath; |
|
66 | 66 | $body = null; |
67 | 67 | if ($this->file && $this->method === 'PUT') { |
68 | 68 | $body = $this->file; |
@@ -20,7 +20,7 @@ |
||
20 | 20 | { |
21 | 21 | $this->config = $config; |
22 | 22 | $this->url = ($this->config->useSsl ? 'https://' : 'http://') . Config::ED_FORM . '/'. |
23 | - $this->config->bucketName; |
|
23 | + $this->config->bucketName; |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | public function __construct(Config $config) |
20 | 20 | { |
21 | 21 | $this->config = $config; |
22 | - $this->url = ($this->config->useSsl ? 'https://' : 'http://') . Config::ED_FORM . '/'. |
|
22 | + $this->url = ($this->config->useSsl ? 'https://' : 'http://').Config::ED_FORM.'/'. |
|
23 | 23 | $this->config->bucketName; |
24 | 24 | } |
25 | 25 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function upload($path, $stream, $fileHash, $params = []) |
36 | 36 | { |
37 | - $path = '/' . ltrim($path, '/'); |
|
37 | + $path = '/'.ltrim($path, '/'); |
|
38 | 38 | $initInfo = $this->initRequest($path, $stream, $fileHash, $params); |
39 | 39 | $blockStatus = $initInfo->status; |
40 | 40 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $multipart[] = [ |
115 | 115 | 'name' => 'file', |
116 | 116 | 'contents' => $fileBlock, |
117 | - 'filename' => 'file', //this value must be file |
|
117 | + 'filename' => 'file', //this value must be file |
|
118 | 118 | 'headers' => ['Content-Type' => 'application/octet-stream'] |
119 | 119 | ]; |
120 | 120 | $postData['file'] = $fileBlock; |