diff --git a/composer.json b/composer.json index 6431520..4581958 100644 --- a/composer.json +++ b/composer.json @@ -7,9 +7,10 @@ "homepage": "https://github.com/upyun/php-sdk/", "license": "MIT", "require": { - "php": ">=5.5.0", + "php": ">=7.0", "ext-curl": "*", - "guzzlehttp/guzzle": "~6.0" + "guzzlehttp/guzzle": "~6.0", + "ext-json": "*" }, "require-dev": { "phpunit/phpunit": "~4.0", diff --git a/src/Upyun/Api/Form.php b/src/Upyun/Api/Form.php index 549c639..924cd9b 100644 --- a/src/Upyun/Api/Form.php +++ b/src/Upyun/Api/Form.php @@ -18,10 +18,8 @@ public function upload($path, $stream, $params) $policy = Util::base64Json($params); $method = 'POST'; - $signature = Signature::getBodySignature($this->config, $method, '/' . $params['service'], null, $policy); - $client = new Client([ - 'timeout' => $this->config->timeout, - ]); + $signature = Signature::getBodySignature($this->config, $method, '/'.$params['service'], null, $policy); + $client = $this->config->getGuzzleClient(); $response = $client->request($method, $this->endpoint, array( 'multipart' => array( diff --git a/src/Upyun/Api/Pretreat.php b/src/Upyun/Api/Pretreat.php index fd17a43..c8d2ae1 100644 --- a/src/Upyun/Api/Pretreat.php +++ b/src/Upyun/Api/Pretreat.php @@ -1,4 +1,5 @@ $this->config->timeout, - ]); + $client = $this->config->getGuzzleClient(); $params = array( 'service' => $this->config->serviceName, @@ -42,7 +41,7 @@ public function process($tasks, $optionalParams = array()) $method = 'POST'; $signedHeaders = Signature::getHeaderSign($this->config, $method, $path); - $url = $this->config->getPretreatEndPoint() . $path; + $url = $this->config->getPretreatEndPoint().$path; $response = $client->request($method, $url, [ 'headers' => $signedHeaders, 'form_params' => $params @@ -55,18 +54,16 @@ public function process($tasks, $optionalParams = array()) public function query($taskIds, $path) { - $client = new Client([ - 'timeout' => $this->config->timeout, - ]); + $client = $this->config->getGuzzleClient(); $params = array( 'service' => $this->config->serviceName, 'task_ids' => implode(',', $taskIds) ); - $path = $path . '?' . http_build_query($params); + $path = $path.'?'.http_build_query($params); $method = 'GET'; - $url = $this->config->getPretreatEndPoint() . $path; + $url = $this->config->getPretreatEndPoint().$path; $signedHeaders = Signature::getHeaderSign($this->config, $method, $path); $response = $client->request($method, $url, [ 'headers' => $signedHeaders diff --git a/src/Upyun/Api/Rest.php b/src/Upyun/Api/Rest.php index be4b0a0..0ef611d 100644 --- a/src/Upyun/Api/Rest.php +++ b/src/Upyun/Api/Rest.php @@ -28,20 +28,20 @@ class Rest public function __construct(Config $config) { - $this->config = $config; - $this->endpoint = $config->getProtocol() . Config::$restApiEndPoint . '/' . $config->serviceName; + $this->config = $config; + $this->endpoint = $config->getProtocol().Config::$restApiEndPoint.'/'.$config->serviceName; } public function request($method, $storagePath) { $this->method = strtoupper($method); - $this->storagePath = '/' . ltrim($storagePath, '/'); + $this->storagePath = '/'.ltrim($storagePath, '/'); return $this; } /** - * @param string|resource $file + * @param string|resource $file * * @return $this */ @@ -58,11 +58,9 @@ public function withFile($file) */ public function send() { - $client = new Client([ - 'timeout' => $this->config->timeout, - ]); + $client = $this->config->getGuzzleClient(); - $url = $this->endpoint . $this->storagePath; + $url = $this->endpoint.$this->storagePath; $body = null; if ($this->file && $this->method === 'PUT') { $body = $this->file; @@ -108,7 +106,7 @@ public function withHeaders($headers) public function toRequest() { - $url = $this->endpoint . $this->storagePath; + $url = $this->endpoint.$this->storagePath; $body = null; if ($this->file && $this->method === 'PUT') { $body = $this->file; diff --git a/src/Upyun/Api/SyncVideo.php b/src/Upyun/Api/SyncVideo.php index 39d1972..6bf71ea 100644 --- a/src/Upyun/Api/SyncVideo.php +++ b/src/Upyun/Api/SyncVideo.php @@ -10,7 +10,8 @@ use Upyun\Signature; -class SyncVideo { +class SyncVideo +{ /** * @var Config */ @@ -21,16 +22,15 @@ public function __construct(Config $config) $this->config = $config; } - public function process($params, $path) { - $client = new Client([ - 'timeout' => $this->config->timeout, - ]); + public function process($params, $path) + { + $client = $this->config->getGuzzleClient(); - $path = '/' . $this->config->serviceName . $path; + $path = '/'.$this->config->serviceName.$path; $method = 'POST'; $signedHeaders = Signature::getHeaderSign($this->config, $method, $path); - $url = $this->config->getSyncVideoEndPoint() . $path; + $url = $this->config->getSyncVideoEndPoint().$path; $response = $client->request($method, $url, [ 'headers' => $signedHeaders, 'json' => $params @@ -39,4 +39,4 @@ public function process($params, $path) { $body = $response->getBody()->getContents(); return json_decode($body, true); } -} \ No newline at end of file +} diff --git a/src/Upyun/Config.php b/src/Upyun/Config.php index 1b99b6c..1a36a55 100644 --- a/src/Upyun/Config.php +++ b/src/Upyun/Config.php @@ -1,6 +1,10 @@ bucketName = $serviceName; $this->operatorName = $operatorName; $this->setOperatorPassword($operatorPassword); - $this->useSsl = false; + $this->useSsl = false; self::$restApiEndPoint = self::ED_AUTO; } + /** + * @param $guzzleHandler + * @return $this + */ + public function setGuzzleHandler($guzzleHandler) + { + $this->guzzleHandler = $guzzleHandler; + + return $this; + } + + /** + * @return HandlerStack|null + */ + public function getGuzzleHandler() + { + if (isset($this->guzzleHandler)) { + $guzzleHandler = $this->guzzleHandler; + return is_string($guzzleHandler) ? new $guzzleHandler() : $guzzleHandler; + } + + return $this->guzzleHandler; + } + + public function getGuzzleClient() + { + return $this->guzzleClient ?? $this->guzzleClient = new Client([ + 'timeout' => $this->timeout, + 'handler' => $this->getGuzzleHandler(), + ]); + } + public function setOperatorPassword($operatorPassword) { $this->operatorPassword = md5($operatorPassword); @@ -118,7 +156,7 @@ public function setOperatorPassword($operatorPassword) public function getFormApiKey() { - if (! $this->formApiKey) { + if (!$this->formApiKey) { throw new \Exception('form api key is empty.'); } @@ -137,12 +175,12 @@ public function getVersion() public function getPretreatEndPoint() { - return $this->getProtocol() . self::ED_VIDEO; + return $this->getProtocol().self::ED_VIDEO; } public function getSyncVideoEndPoint() { - return $this->getProtocol() . self::ED_SYNC_VIDEO; + return $this->getProtocol().self::ED_SYNC_VIDEO; } public function getProtocol() diff --git a/src/Upyun/Uploader.php b/src/Upyun/Uploader.php index 95e6f2f..a6c2cdb 100644 --- a/src/Upyun/Uploader.php +++ b/src/Upyun/Uploader.php @@ -1,4 +1,5 @@ upload($path, $stream, $params); } - if (! $useBlock) { + if (!$useBlock) { $req = new Rest($this->config); return $req->request('PUT', $path) - ->withHeaders($params) - ->withFile($stream) - ->send(); + ->withHeaders($params) + ->withFile($stream) + ->send(); } elseif ($this->config->uploadType === 'BLOCK_PARALLEL') { return $this->concurrentPointUpload($path, $stream, $params); } else { @@ -61,7 +62,7 @@ private function pointUpload($path, $stream, $params) $headers = array(); if (is_array($params)) { foreach ($params as $key => $val) { - $headers['X-Upyun-Meta-' . $key] = $val; + $headers['X-Upyun-Meta-'.$key] = $val; } } $res = $req->request('PUT', $path) @@ -75,10 +76,10 @@ private function pointUpload($path, $stream, $params) throw new \Exception('init request failed when poinit upload!'); } - $init = Util::getHeaderParams($res->getHeaders()); - $uuid = $init['x-upyun-multi-uuid']; + $init = Util::getHeaderParams($res->getHeaders()); + $uuid = $init['x-upyun-multi-uuid']; $blockSize = 1024 * 1024; - $partId = 0; + $partId = 0; do { $fileBlock = $stream->read($blockSize); $res = $req->request('PUT', $path) @@ -93,7 +94,7 @@ private function pointUpload($path, $stream, $params) if ($res->getStatusCode() !== 204) { throw new \Exception('upload request failed when poinit upload!'); } - $data = Util::getHeaderParams($res->getHeaders()); + $data = Util::getHeaderParams($res->getHeaders()); $partId = $data['x-upyun-next-part-id']; } while ($partId != -1); @@ -116,7 +117,7 @@ private function needUseBlock($fileSize) $this->config->uploadType === 'BLOCK_PARALLEL') { return true; } elseif ($this->config->uploadType === 'AUTO' && - $fileSize >= $this->config->sizeBoundary) { + $fileSize >= $this->config->sizeBoundary) { return true; } else { return false; @@ -139,7 +140,7 @@ private function concurrentPointUpload($path, $stream, $params) $headers = array(); if (is_array($params)) { foreach ($params as $key => $val) { - $headers['X-Upyun-Meta-' . $key] = $val; + $headers['X-Upyun-Meta-'.$key] = $val; } } $res = $req->request('PUT', $path) @@ -171,9 +172,7 @@ private function concurrentPointUpload($path, $stream, $params) ->toRequest(); } }; - $client = new Client([ - 'timeout' => $this->config->timeout, - ]); + $client = $this->config->getGuzzleClient(); $pool = new Pool($client, $requests($req, $path, $stream, $uuid), [ 'concurrency' => $this->config->concurrency, 'fulfilled' => function ($res) { diff --git a/src/Upyun/Upyun.php b/src/Upyun/Upyun.php index e74c6c7..3b509e0 100644 --- a/src/Upyun/Upyun.php +++ b/src/Upyun/Upyun.php @@ -2,6 +2,7 @@ /** * 又拍云 PHP-SDK */ + namespace Upyun; use Upyun\Api\Rest; @@ -57,7 +58,7 @@ class Upyun /** * Upyun constructor. * - * @param Config $config 服务配置 + * @param Config $config 服务配置 */ public function __construct(Config $config) { @@ -69,7 +70,7 @@ public function __construct(Config $config) * * 当需要操作的新的服务时,使用该方法传入新的服务配置即可 * - * @param Config $config 服务配置 + * @param Config $config 服务配置 * * @return $this */ @@ -84,14 +85,14 @@ public function setConfig(Config $config) * * 上传的文件格式支持文件流或者字符串方式上传。除简单的文件上传外,针对多媒体资源(图片、音视频),还可以设置同步/异步预处理多媒体资源,例如:图片的裁剪缩放,音视频的转码截图等等众多又拍云强大的云处理功能 * - * @param string $path 被上传的文件在又拍云存储服务中保存的路径 - * @param string|resource $content 被上传的文件内容(字符串),或者打开该文件获得的文件句柄(文件流)。当上传本地大文件时,推荐使用文件流的方式上传 - * @param array $params 上传文件时,附加的自定义参数。支持 Content-MD5 Content-Type Content-Secret 等,详见 [上传参数](http://docs.upyun.com/api/rest_api/#_2),例如: + * @param string $path 被上传的文件在又拍云存储服务中保存的路径 + * @param string|resource $content 被上传的文件内容(字符串),或者打开该文件获得的文件句柄(文件流)。当上传本地大文件时,推荐使用文件流的方式上传 + * @param array $params 上传文件时,附加的自定义参数。支持 Content-MD5 Content-Type Content-Secret 等,详见 [上传参数](http://docs.upyun.com/api/rest_api/#_2),例如: * - 设置文件[保护秘钥](http://docs.upyun.com/api/rest_api/#Content-Secret) `write($path, $content, array('Content-Secret' => 'my-secret'))`; * - 添加[文件元信息](http://docs.upyun.com/api/rest_api/#metadata) `write($path, $content, array('X-Upyun-Meta-Foo' => * 'bar'))` * - [图片同步预处理](http://docs.upyun.com/cloud/image/#_5) `write($path, $content, array('x-gmkerl-thumb' => '/format/png'))` - * @param bool $withAsyncProcess 默认为 `false`,当上传图片或者音视频资源时,可以设置该参数为 `true`,开启图片音视频的[异步处理功能](http://docs.upyun.com/api/form_api/#_6) ,例如: + * @param bool $withAsyncProcess 默认为 `false`,当上传图片或者音视频资源时,可以设置该参数为 `true`,开启图片音视频的[异步处理功能](http://docs.upyun.com/api/form_api/#_6) ,例如: *``` * // 以下参数会将新上传的图片,再异步生成另一份 png 格式的图片,原图不受影响 * write($path, $content, array( @@ -130,10 +131,10 @@ public function write($path, $content, $params = array(), $withAsyncProcess = fa /** * 读取云存储文件/目录内容 * - * @param string $path 又拍云存储中的文件或者目录路径 - * @param resource $saveHandler 文件内容写入本地文件流。例如 `$saveHandler = fopen('/local/file', 'w') + * @param string $path 又拍云存储中的文件或者目录路径 + * @param resource $saveHandler 文件内容写入本地文件流。例如 `$saveHandler = fopen('/local/file', 'w') * `。当设置该参数时,将以文件流的方式,直接将又拍云中的文件写入本地的文件流,或其他可以写入的流 - * @param array $params 可选参数,读取目录内容时,需要设置三个参数: `X-List-Iter` 分页开始位置(第一页不需要设置),`X-List-Limit` 获取的文件数量(默认 100,最大 + * @param array $params 可选参数,读取目录内容时,需要设置三个参数: `X-List-Iter` 分页开始位置(第一页不需要设置),`X-List-Limit` 获取的文件数量(默认 100,最大 * 10000),`X-List-Order` 结果以时间正序或者倒序 * * @return mixed $return 当读取文件且没有设置 `$saveHandler` 参数时,返回一个字符串类型,表示文件内容;设置了 `$saveHandler` 参数时,返回布尔值 @@ -152,7 +153,7 @@ public function read($path, $saveHandler = null, $params = array()) $params = Util::getHeaderParams($response->getHeaders()); - if (! isset($params['x-upyun-list-iter'])) { + if (!isset($params['x-upyun-list-iter'])) { if (is_resource($saveHandler)) { Psr7\copy_to_stream($response->getBody(), Psr7\stream_for($saveHandler)); return true; @@ -161,7 +162,10 @@ public function read($path, $saveHandler = null, $params = array()) } } else { $files = Util::parseDir($response->getBody()->getContents()); - return array('files' => $files, 'is_end' => $params['x-upyun-list-iter'] === 'g2gCZAAEbmV4dGQAA2VvZg', 'iter' => $params['x-upyun-list-iter']); + return array( + 'files' => $files, 'is_end' => $params['x-upyun-list-iter'] === 'g2gCZAAEbmV4dGQAA2VvZg', + 'iter' => $params['x-upyun-list-iter'] + ); } } @@ -170,7 +174,7 @@ public function read($path, $saveHandler = null, $params = array()) * * 注意: 对刚删除的文件, 立即调用该方法可能会返回 true, 因为服务端执行删除操作后可能会有很短暂的延迟. * - * @param string $path 云存储的文件路径 + * @param string $path 云存储的文件路径 * * @return bool 存在时返回 `true`,否则返回 `false` * @throws \Exception @@ -180,7 +184,7 @@ public function has($path) $req = new Rest($this->config); try { $req->request('HEAD', $path) - ->send(); + ->send(); } catch (GuzzleHttp\Exception\BadResponseException $e) { $statusCode = $e->getResponse()->getStatusCode(); if ($statusCode === 404) { @@ -196,8 +200,8 @@ public function has($path) /** * 获取云存储文件/目录的基本信息 * - * @param string $path 云存储的文件路径 - * @param array $otherHeaders 设置了后,方法将返回其他 http header 中的信息,默认为空 + * @param string $path 云存储的文件路径 + * @param array $otherHeaders 设置了后,方法将返回其他 http header 中的信息,默认为空 * * @return array 返回一个数组,默认包含以下 key * - `x-upyun-file-type` 当 $path 是目录时,值为 *folder*,当 $path 是文件时,值为 *file*, @@ -208,13 +212,13 @@ public function info($path, $otherHeaders = array()) { $req = new Rest($this->config); $response = $req->request('HEAD', $path) - ->send(); + ->send(); return Util::getHeaderParams($response->getHeaders(), $otherHeaders); } /** * 获取文件的文档类型 - * @param string $path 云存储文件路径 + * @param string $path 云存储文件路径 * @return string 文档类型,e.g: `appcation/json`,获取失败返回空字符串 */ public function getMimetype($path) @@ -229,8 +233,8 @@ public function getMimetype($path) /** * 删除文件或者目录 * - * @param string $path 文件或目录在又拍云存储的路径 - * @param bool $async 是否异步删除,默认为 false,表示同步删除。当需要批量删除大量文件时,必须选择异步删除 + * @param string $path 文件或目录在又拍云存储的路径 + * @param bool $async 是否异步删除,默认为 false,表示同步删除。当需要批量删除大量文件时,必须选择异步删除 * * @return bool 删除成功返回 true,否则 false * @throws \Exception 删除不存在的文件将会抛出异常 @@ -249,14 +253,14 @@ public function delete($path, $async = false) /** * 创建目录 * - * @param string $path 需要在又拍云存储创建的目录路径 + * @param string $path 需要在又拍云存储创建的目录路径 * * @return bool 创建成功返回 true,否则返回 false * @throws \Exception */ public function createDir($path) { - $path = rtrim($path, '/') . '/'; + $path = rtrim($path, '/').'/'; $req = new Rest($this->config); $res = $req->request('POST', $path) ->withHeader('folder', 'true') @@ -267,7 +271,7 @@ public function createDir($path) /** * 删除文件或者目录 * - * @param string $path 需要被删除的云存储文件或目录路径 + * @param string $path 需要被删除的云存储文件或目录路径 * * @return bool 成功返回 true,否则 false * @throws \Exception @@ -280,15 +284,15 @@ public function deleteDir($path) /** * 获取目录下存储使用量 * - * @param string $path 云存储目录路径,默认为根目录,表示整个云存储服务使用的空间大小 + * @param string $path 云存储目录路径,默认为根目录,表示整个云存储服务使用的空间大小 * @return string 存储使用量,单位字节 * @throws \Exception */ public function usage($path = '/') { - $path = rtrim($path, '/') . '/'; + $path = rtrim($path, '/').'/'; $req = new Rest($this->config); - $response = $req->request('GET', $path . '?usage') + $response = $req->request('GET', $path.'?usage') ->send(); return $response->getBody()->getContents(); @@ -297,14 +301,14 @@ public function usage($path = '/') /** * 复制文件。只能操作文件,不能操作文件夹。 * - * @param string $source 源文件地址 - * @param string $target 目标文件地址 + * @param string $source 源文件地址 + * @param string $target 目标文件地址 * @return bool 复制成功返回 true,否则 false * @throws \Exception */ public function copy($source, $target) { - $source = '/' . $this->config->serviceName . '/' . ltrim($source, '/'); + $source = '/'.$this->config->serviceName.'/'.ltrim($source, '/'); $req = new Rest($this->config); $response = $req->request('PUT', $target) ->withHeader('X-Upyun-Copy-Source', $source) @@ -315,14 +319,14 @@ public function copy($source, $target) /** * 移动文件。可以进行文件重命名、文件移动,只能操作文件,不能操作文件夹。 * - * @param string $source 源文件地址 - * @param string $target 目标文件地址 + * @param string $source 源文件地址 + * @param string $target 目标文件地址 * @return bool 移动成功返回 true,否则 false * @throws \Exception */ public function move($source, $target) { - $source = '/' . $this->config->serviceName . '/' . ltrim($source, '/'); + $source = '/'.$this->config->serviceName.'/'.ltrim($source, '/'); $req = new Rest($this->config); $response = $req->request('PUT', $target) ->withHeader('X-Upyun-Move-Source', $source) @@ -333,7 +337,7 @@ public function move($source, $target) /** * 刷新缓存 * - * @param array|string $urls 需要刷新的文件 url 列表 + * @param array|string $urls 需要刷新的文件 url 列表 * * @return array 刷新失败的 url 列表,若全部刷新成功则为空数组 */ @@ -344,11 +348,9 @@ public function purge($urls) $urlString = implode("\n", $urls); } - $client = new Client([ - 'timeout' => $this->config->timeout - ]); + $client = $this->config->getGuzzleClient(); $response = $client->request('POST', Config::ED_PURGE, [ - 'headers' => Signature::getPurgeSignHeader($this->config, $urlString), + 'headers' => Signature::getPurgeSignHeader($this->config, $urlString), 'form_params' => ['purge' => $urlString] ]); $result = json_decode($response->getBody()->getContents(), true); @@ -376,14 +378,14 @@ public function purge($urls) * ), Upyun::$PROCESS_TYPE_MEDIA, $source) * ``` * - * @param array $tasks 需要处理的任务 - * @param string $type 异步云处理任务类型,可选值: + * @param array $tasks 需要处理的任务 + * @param string $type 异步云处理任务类型,可选值: * - `Upyun::$PROCESS_TYPE_MEDIA` 异步音视频处理 * - `Upyun::$PROCESS_TYPE_ZIP` 文件压缩 * - `Upyun::$PROCESS_TYPE_UNZIP` 文件解压 * - `Upyun::$PROCESS_TYPE_SYNC_FILE` 文件拉取 * - `Upyun::$PROCESS_TYPE_STITCH` 图片拼接 - * @param string $source 可选参数,处理异步音视频任务时,需要传递该参数,表示需要处理的文件路径 + * @param string $source 可选参数,处理异步音视频任务时,需要传递该参数,表示需要处理的文件路径 * * @return array 任务 ID,提交了多少任务,便会返回多少任务 ID,与提交任务的顺序保持一致。可以通过任务 ID 查询处理进度。格式如下: * ``` @@ -399,7 +401,7 @@ public function process($tasks, $type, $source = '') $video = new Api\Pretreat($this->config); $options = array(); - switch($type) { + switch ($type) { case self::$PROCESS_TYPE_MEDIA: $options['accept'] = 'json'; $options['source'] = $source; @@ -431,7 +433,7 @@ public function process($tasks, $type, $source = '') * * 根据 `process` 方法返回的任务 ID,通过该访问查询处理进度 * - * @param array $taskIds 任务 ID + * @param array $taskIds 任务 ID * * @return bool|array 查询失败返回布尔值 `false`,否则返回每个任务的百分比进度信息,格式如下: * ``` @@ -452,7 +454,7 @@ public function queryProcessStatus($taskIds) * 查询异步云处理任务结果 * * 根据 `process` 方法返回的任务 ID,通过该访问查询处理结果,会包含每个任务详细信息 - * @param array $taskIds 任务 ID + * @param array $taskIds 任务 ID * * @return bool|mixed 查询失败返回 `false`,否则返回每个任务的处理结果,格式如下: * ``` @@ -477,8 +479,8 @@ public function queryProcessResult($taskIds) /** * 多个 m3u8 文件拼接 - * @param array $files 保存在又拍云云存储中的多个 m3u8 文件路径 - * @param string $saveAs 拼接生成的新 m3u8 文件保存路径 + * @param array $files 保存在又拍云云存储中的多个 m3u8 文件路径 + * @param string $saveAs 拼接生成的新 m3u8 文件保存路径 * * @return array 见 [m3u8 拼接 - 响应](http://docs.upyun.com/cloud/sync_video/#_3) */ @@ -493,11 +495,11 @@ public function m3u8Concat($files, $saveAs) /** * 单个 m3u8 文件剪辑 - * @param string $file 需要剪辑的又拍云云存储中的 m3u8 文件路径 - * @param string $saveAs 剪辑完成后新的 m3u8 文件保存路径 - * @param array $slice 需要被保留或删除的片段。 - * @param bool $isInclude 默认为 `true` 表示 `$slice` 参数描述的片段被保留,否则表示 `$slice` 参数描述的片段被删除 - * @param bool $index 指定 `$slice` 参数的格式,默认为 `false` 表示使用时间范围描述片段,单位秒:`[<开始时间>, <结束时间>]`;`true` 表示使用 `m3u8` 文件的分片序号,从 0 开始,这种方式可以一次对多个片段操作 + * @param string $file 需要剪辑的又拍云云存储中的 m3u8 文件路径 + * @param string $saveAs 剪辑完成后新的 m3u8 文件保存路径 + * @param array $slice 需要被保留或删除的片段。 + * @param bool $isInclude 默认为 `true` 表示 `$slice` 参数描述的片段被保留,否则表示 `$slice` 参数描述的片段被删除 + * @param bool $index 指定 `$slice` 参数的格式,默认为 `false` 表示使用时间范围描述片段,单位秒:`[<开始时间>, <结束时间>]`;`true` 表示使用 `m3u8` 文件的分片序号,从 0 开始,这种方式可以一次对多个片段操作 * * @return array 见 [m3u8 剪辑 - 响应](http://docs.upyun.com/cloud/sync_video/#_6) */ @@ -519,7 +521,7 @@ public function m3u8Clip($file, $saveAs, $slice = array(), $isInclude = true, $i /** * 获取单个 m3u8 文件描述信息 - * @param string $file 又拍云云存储的中的 m3u8 文件路径 + * @param string $file 又拍云云存储的中的 m3u8 文件路径 * * @return array 见 [获取 m3u8 信息 - 响应](http://docs.upyun.com/cloud/sync_video/#_6) */ @@ -533,11 +535,11 @@ public function m3u8Meta($file) /** * 视频截图,可以对 mp4、m3u8 等视频文件进行截图 - * @param string $file 需要截图的又拍云云存储中的视频文件路径 - * @param string $saveAs 截图保存路径 - * @param string $point 截图时间点,`HH:MM:SS` 格式 - * @param string $size 截图尺寸 `宽x高` 格式的字符串。默认和视频尺寸一致 - * @param string $format 截图保存的格式,默认根据 `$saveAs` 参数的后缀生成,可以指定 `jpg | png | webp` 三种格式 + * @param string $file 需要截图的又拍云云存储中的视频文件路径 + * @param string $saveAs 截图保存路径 + * @param string $point 截图时间点,`HH:MM:SS` 格式 + * @param string $size 截图尺寸 `宽x高` 格式的字符串。默认和视频尺寸一致 + * @param string $format 截图保存的格式,默认根据 `$saveAs` 参数的后缀生成,可以指定 `jpg | png | webp` 三种格式 * * @return array 见 [视频截图 - 响应](http://docs.upyun.com/cloud/sync_video/#m3u8_2) */ @@ -560,7 +562,7 @@ public function snapshot($file, $saveAs, $point, $size = '', $format = '') /** * 获取音视频文件元信息 - * @param string $file 又拍云云存储的中的音视频文件路径 + * @param string $file 又拍云云存储的中的音视频文件路径 * * @return array 见 [获取音视频文件信息 - 响应](http://docs.upyun.com/cloud/sync_video/#_16) */