@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @param string $srcPath 本地文件路径 |
48 | 48 | * @param string $dstPath 上传的文件路径 |
49 | 49 | * @param string $bizAttr 文件属性 |
50 | - * @param string $slicesize 分片大小(512k,1m,2m,3m),默认:1m |
|
50 | + * @param string $sliceSize 分片大小(512k,1m,2m,3m),默认:1m |
|
51 | 51 | * @param string $insertOnly 同名文件是否覆盖 |
52 | 52 | * |
53 | 53 | * @return [type] [description] |
@@ -127,6 +127,10 @@ discard block |
||
127 | 127 | * @param int $order 默认正序(=0), 填1为反序, |
128 | 128 | * @param string $offset 透传字段,用于翻页,前端不需理解,需要往前/往后翻页则透传回来 |
129 | 129 | */ |
130 | + |
|
131 | + /** |
|
132 | + * @param string $folder |
|
133 | + */ |
|
130 | 134 | public static function listFolder( |
131 | 135 | $bucket, $folder, $num = 20, |
132 | 136 | $pattern = 'eListBoth', $order = 0, |
@@ -212,6 +216,10 @@ discard block |
||
212 | 216 | * 'Content-Language' => '*' |
213 | 217 | * 'x-cos-meta-自定义内容' => '*' |
214 | 218 | */ |
219 | + |
|
220 | + /** |
|
221 | + * @param string $authority |
|
222 | + */ |
|
215 | 223 | public static function update($bucket, $path, |
216 | 224 | $bizAttr = null, $authority = null, $customer_headers_array = null) |
217 | 225 | { |
@@ -308,8 +316,8 @@ discard block |
||
308 | 316 | * 内部方法,上传文件. |
309 | 317 | * |
310 | 318 | * @param string $bucket bucket名称 |
311 | - * @param string $srcPath 本地文件路径 |
|
312 | - * @param string $dstPath 上传的文件路径 |
|
319 | + * @param string $srcFpath 本地文件路径 |
|
320 | + * @param string $dstFpath 上传的文件路径 |
|
313 | 321 | * @param string $bizAttr 文件属性 |
314 | 322 | * @param string $sliceSize 分片大小 |
315 | 323 | * @param int $insertOnly 是否覆盖同名文件:0 覆盖,1:不覆盖 |
@@ -625,6 +633,7 @@ discard block |
||
625 | 633 | |
626 | 634 | /** |
627 | 635 | * Get slice size. |
636 | + * @param string|null $sliceSize |
|
628 | 637 | */ |
629 | 638 | private static function getSliceSize($sliceSize) |
630 | 639 | { |
@@ -674,8 +683,8 @@ discard block |
||
674 | 683 | /** |
675 | 684 | * 判断pattern值是否正确. |
676 | 685 | * |
677 | - * @param string $authority |
|
678 | 686 | * |
687 | + * @param string $pattern |
|
679 | 688 | * @return [type] bool |
680 | 689 | */ |
681 | 690 | private static function isPatternValid($pattern) |
@@ -729,6 +738,10 @@ discard block |
||
729 | 738 | |
730 | 739 | // Check |$path| is a valid file path. |
731 | 740 | // Return true on success, otherwise return false. |
741 | + |
|
742 | + /** |
|
743 | + * @param string $path |
|
744 | + */ |
|
732 | 745 | private static function isValidPath($path) |
733 | 746 | { |
734 | 747 | if (strpos($path, '?') !== false) { |
@@ -763,8 +776,8 @@ discard block |
||
763 | 776 | * Copy a file. |
764 | 777 | * |
765 | 778 | * @param $bucket bucket name. |
766 | - * @param $srcFpath source file path. |
|
767 | - * @param $dstFpath destination file path. |
|
779 | + * @param string $srcFpath source file path. |
|
780 | + * @param string $dstFpath destination file path. |
|
768 | 781 | * @param $overwrite if the destination location is occupied, overwrite it or not? |
769 | 782 | * |
770 | 783 | * @return array|mixed. |
@@ -795,8 +808,8 @@ discard block |
||
795 | 808 | * Move a file. |
796 | 809 | * |
797 | 810 | * @param $bucket bucket name. |
798 | - * @param $srcFpath source file path. |
|
799 | - * @param $dstFpath destination file path. |
|
811 | + * @param string $srcFpath source file path. |
|
812 | + * @param string $dstFpath destination file path. |
|
800 | 813 | * @param $overwrite if the destination location is occupied, overwrite it or not? |
801 | 814 | * |
802 | 815 | * @return array|mixed. |
@@ -213,7 +213,7 @@ |
||
213 | 213 | * 'x-cos-meta-自定义内容' => '*' |
214 | 214 | */ |
215 | 215 | public static function update($bucket, $path, |
216 | - $bizAttr = null, $authority = null, $customer_headers_array = null) |
|
216 | + $bizAttr = null, $authority = null, $customer_headers_array = null) |
|
217 | 217 | { |
218 | 218 | $path = self::normalizerPath($path); |
219 | 219 |
@@ -30,9 +30,9 @@ |
||
30 | 30 | }); |
31 | 31 | |
32 | 32 | Storage::disk('cosv4') |
33 | - ->addPlugin(new PutRemoteFile()) |
|
34 | - ->addPlugin(new PutRemoteFileAs()) |
|
35 | - ->addPlugin(new GetUrl()); |
|
33 | + ->addPlugin(new PutRemoteFile()) |
|
34 | + ->addPlugin(new PutRemoteFileAs()) |
|
35 | + ->addPlugin(new GetUrl()); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -25,7 +25,7 @@ |
||
25 | 25 | __DIR__.'/filesystems.php' => config_path('filesystems.php'), |
26 | 26 | ]); |
27 | 27 | |
28 | - Storage::extend('cosv4', function ($app, $config) { |
|
28 | + Storage::extend('cosv4', function($app, $config) { |
|
29 | 29 | return new Filesystem(new Adapter($config)); |
30 | 30 | }); |
31 | 31 |
@@ -5,10 +5,10 @@ discard block |
||
5 | 5 | // A simple wrapper for libcurl using multi interface to do transfers in parallel. |
6 | 6 | class LibcurlWrapper |
7 | 7 | { |
8 | - private $sequence; // integer: sequence id for each request. |
|
8 | + private $sequence; // integer: sequence id for each request. |
|
9 | 9 | private $curlMultiHandle; // curl handle: curl multi handle. |
10 | - private $curlHandleInfo; // array: array of active curl handle. |
|
11 | - private $idleCurlHandle; // array: idle curl handle which can be reused. |
|
10 | + private $curlHandleInfo; // array: array of active curl handle. |
|
11 | + private $idleCurlHandle; // array: idle curl handle which can be reused. |
|
12 | 12 | |
13 | 13 | public function __construct() |
14 | 14 | { |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | public function performSendingRequest() |
69 | 69 | { |
70 | - for (; ;) { |
|
70 | + for (;;) { |
|
71 | 71 | $active = null; |
72 | 72 | |
73 | 73 | do { |
@@ -84,8 +84,8 @@ |
||
84 | 84 | curl_setopt(self::$curlHandler, CURLOPT_SSLVERSION, 4); |
85 | 85 | } |
86 | 86 | } elseif ($ssl) { |
87 | - curl_setopt(self::$curlHandler, CURLOPT_SSL_VERIFYPEER, false); //true any ca |
|
88 | - curl_setopt(self::$curlHandler, CURLOPT_SSL_VERIFYHOST, 1); //check only host |
|
87 | + curl_setopt(self::$curlHandler, CURLOPT_SSL_VERIFYPEER, false); //true any ca |
|
88 | + curl_setopt(self::$curlHandler, CURLOPT_SSL_VERIFYHOST, 1); //check only host |
|
89 | 89 | if (isset($request['ssl_version'])) { |
90 | 90 | curl_setopt(self::$curlHandler, CURLOPT_SSLVERSION, $request['ssl_version']); |
91 | 91 | } else { |
@@ -4,9 +4,9 @@ |
||
4 | 4 | |
5 | 5 | class HttpResponse |
6 | 6 | { |
7 | - public $curlErrorCode; // int: curl last error code. |
|
7 | + public $curlErrorCode; // int: curl last error code. |
|
8 | 8 | public $curlErrorMessage; // string: curl last error message. |
9 | - public $statusCode; // int: http status code. |
|
10 | - public $headers; // array: response headers. |
|
11 | - public $body; // string: response body. |
|
9 | + public $statusCode; // int: http status code. |
|
10 | + public $headers; // array: response headers. |
|
11 | + public $body; // string: response body. |
|
12 | 12 | } |
@@ -10,26 +10,26 @@ |
||
10 | 10 | // default task number for concurrently uploading slices. |
11 | 11 | const DEFAULT_CONCURRENT_TASK_NUMBER = 3; |
12 | 12 | |
13 | - private $timeoutMs; // int: timeout in milliseconds for each http request. |
|
14 | - private $maxRetryCount; // int: max retry count on failure. |
|
15 | - |
|
16 | - private $errorCode; // int: last error code. |
|
17 | - private $errorMessage; // string: last error message. |
|
18 | - private $requestId; // string: request id for last http request. |
|
19 | - private $signature; // string: signature for auth. |
|
20 | - private $srcFpath; // string: source file path for uploading. |
|
21 | - private $url; // string: destination url for uploading. |
|
22 | - private $fileSize; // int: source file size. |
|
23 | - private $sliceSize; // int: slice size for each upload. |
|
24 | - private $session; // string: session for each upload transaction. |
|
13 | + private $timeoutMs; // int: timeout in milliseconds for each http request. |
|
14 | + private $maxRetryCount; // int: max retry count on failure. |
|
15 | + |
|
16 | + private $errorCode; // int: last error code. |
|
17 | + private $errorMessage; // string: last error message. |
|
18 | + private $requestId; // string: request id for last http request. |
|
19 | + private $signature; // string: signature for auth. |
|
20 | + private $srcFpath; // string: source file path for uploading. |
|
21 | + private $url; // string: destination url for uploading. |
|
22 | + private $fileSize; // int: source file size. |
|
23 | + private $sliceSize; // int: slice size for each upload. |
|
24 | + private $session; // string: session for each upload transaction. |
|
25 | 25 | private $concurrentTaskNumber; // int: concurrent uploading task number. |
26 | 26 | |
27 | - private $offset; // int: current uploading offset. |
|
28 | - private $libcurlWrapper; // LibcurlWrapper: curl wrapper for sending multi http request concurrently. |
|
27 | + private $offset; // int: current uploading offset. |
|
28 | + private $libcurlWrapper; // LibcurlWrapper: curl wrapper for sending multi http request concurrently. |
|
29 | 29 | |
30 | - private $accessUrl; // string: access url. |
|
31 | - private $resourcePath; // string: resource path. |
|
32 | - private $sourceUrl; // string: source url. |
|
30 | + private $accessUrl; // string: access url. |
|
31 | + private $resourcePath; // string: resource path. |
|
32 | + private $sourceUrl; // string: source url. |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * timeoutMs: max timeout in milliseconds for each http request. |
@@ -4,10 +4,10 @@ |
||
4 | 4 | |
5 | 5 | class HttpRequest |
6 | 6 | { |
7 | - public $timeoutMs; // int: the maximum number of milliseconds to perform this request. |
|
8 | - public $url; // string: the url this request will be sent to. |
|
9 | - public $method; // string: POST or GET. |
|
10 | - public $customHeaders; // array: custom modified, removed and added headers. |
|
11 | - public $dataToPost; // array: the data to post. |
|
12 | - public $userData; // any: user custom data. |
|
7 | + public $timeoutMs; // int: the maximum number of milliseconds to perform this request. |
|
8 | + public $url; // string: the url this request will be sent to. |
|
9 | + public $method; // string: POST or GET. |
|
10 | + public $customHeaders; // array: custom modified, removed and added headers. |
|
11 | + public $dataToPost; // array: the data to post. |
|
12 | + public $userData; // any: user custom data. |
|
13 | 13 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | try { |
80 | 80 | $response = Cosapi::upload($this->getBucket(), $tmpfname, $path, |
81 | - null, null, $config->get('insertOnly', 1)); |
|
81 | + null, null, $config->get('insertOnly', 1)); |
|
82 | 82 | |
83 | 83 | $this->deleteTempFile($tmpfname); |
84 | 84 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $uri = stream_get_meta_data($resource)['uri']; |
113 | 113 | |
114 | 114 | $response = Cosapi::upload($this->getBucket(), $uri, $path, |
115 | - null, null, $config->get('insertOnly', 1)); |
|
115 | + null, null, $config->get('insertOnly', 1)); |
|
116 | 116 | |
117 | 117 | $response = $this->normalizeResponse($response); |
118 | 118 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | |
141 | 141 | try { |
142 | 142 | $response = Cosapi::upload($this->getBucket(), $tmpfname, $path, |
143 | - null, null, $config->get('insertOnly', 0)); |
|
143 | + null, null, $config->get('insertOnly', 0)); |
|
144 | 144 | |
145 | 145 | $this->deleteTempFile($tmpfname); |
146 | 146 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $uri = stream_get_meta_data($resource)['uri']; |
175 | 175 | |
176 | 176 | $response = Cosapi::upload($this->getBucket(), $uri, $path, |
177 | - null, null, $config->get('insertOnly', 0)); |
|
177 | + null, null, $config->get('insertOnly', 0)); |
|
178 | 178 | |
179 | 179 | $response = $this->normalizeResponse($response); |
180 | 180 |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
57 | - * @param $path |
|
57 | + * @param string $path |
|
58 | 58 | * |
59 | 59 | * @return string |
60 | 60 | */ |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | } |
396 | 396 | |
397 | 397 | /** |
398 | - * @param $content |
|
398 | + * @param string $content |
|
399 | 399 | * |
400 | 400 | * @return string|bool |
401 | 401 | */ |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | } |
412 | 412 | |
413 | 413 | /** |
414 | - * @param $tmpfname |
|
414 | + * @param string|boolean $tmpfname |
|
415 | 415 | * |
416 | 416 | * @return bool |
417 | 417 | */ |
@@ -421,8 +421,8 @@ discard block |
||
421 | 421 | } |
422 | 422 | |
423 | 423 | /** |
424 | - * @param $path |
|
425 | - * @param $content |
|
424 | + * @param string $path |
|
425 | + * @param string $content |
|
426 | 426 | * |
427 | 427 | * @return bool |
428 | 428 | */ |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | throw $exception; |
96 | 96 | } |
97 | 97 | |
98 | - return (bool)$response; |
|
98 | + return (bool) $response; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | |
123 | 123 | $this->setContentType($path, stream_get_contents($resource)); |
124 | 124 | |
125 | - return (bool)$response; |
|
125 | + return (bool) $response; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | throw $exception; |
158 | 158 | } |
159 | 159 | |
160 | - return (bool)$response; |
|
160 | + return (bool) $response; |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | |
185 | 185 | $this->setContentType($path, stream_get_contents($resource)); |
186 | 186 | |
187 | - return (bool)$response; |
|
187 | + return (bool) $response; |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public function rename($path, $newpath) |
197 | 197 | { |
198 | - return (bool)$this->normalizeResponse( |
|
198 | + return (bool) $this->normalizeResponse( |
|
199 | 199 | Cosapi::moveFile($this->getBucket(), $path, $newpath, 1) |
200 | 200 | ); |
201 | 201 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | */ |
209 | 209 | public function copy($path, $newpath) |
210 | 210 | { |
211 | - return (bool)$this->normalizeResponse( |
|
211 | + return (bool) $this->normalizeResponse( |
|
212 | 212 | Cosapi::copyFile($this->getBucket(), $path, $newpath, 1) |
213 | 213 | ); |
214 | 214 | } |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | */ |
221 | 221 | public function delete($path) |
222 | 222 | { |
223 | - return (bool)$this->normalizeResponse( |
|
223 | + return (bool) $this->normalizeResponse( |
|
224 | 224 | Cosapi::delFile($this->getBucket(), $path) |
225 | 225 | ); |
226 | 226 | } |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | */ |
233 | 233 | public function deleteDir($dirname) |
234 | 234 | { |
235 | - return (bool)$this->normalizeResponse( |
|
235 | + return (bool) $this->normalizeResponse( |
|
236 | 236 | Cosapi::delFolder($this->getBucket(), $dirname) |
237 | 237 | ); |
238 | 238 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | */ |
246 | 246 | public function createDir($dirname, Config $config) |
247 | 247 | { |
248 | - return (bool)$this->normalizeResponse( |
|
248 | + return (bool) $this->normalizeResponse( |
|
249 | 249 | Cosapi::createFolder($this->getBucket(), $dirname) |
250 | 250 | ); |
251 | 251 | } |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | { |
261 | 261 | $visibility = $visibility === AdapterInterface::VISIBILITY_PUBLIC ? 'eWPrivateRPublic' : 'eWRPrivate'; |
262 | 262 | |
263 | - return (bool)$this->normalizeResponse( |
|
263 | + return (bool) $this->normalizeResponse( |
|
264 | 264 | Cosapi::update($this->getBucket(), $path, null, $visibility) |
265 | 265 | ); |
266 | 266 | } |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | public function has($path) |
274 | 274 | { |
275 | 275 | try { |
276 | - return (bool)$this->getMetadata($path); |
|
276 | + return (bool) $this->getMetadata($path); |
|
277 | 277 | } catch (RuntimeException $exception) { |
278 | 278 | return false; |
279 | 279 | } |