@@ -12,7 +12,7 @@ |
||
12 | 12 | { |
13 | 13 | public function boot() |
14 | 14 | { |
15 | - app('filesystem')->extend('wantu', function ($app, $config) { |
|
15 | + app('filesystem')->extend('wantu', function($app, $config) { |
|
16 | 16 | $adapter = new WantuFileAdapter( |
17 | 17 | $config['access_key'], |
18 | 18 | $config['secret_key'], |
@@ -355,7 +355,7 @@ |
||
355 | 355 | return $this->client->getUploadToken(collect([ |
356 | 356 | 'expiration' => Carbon::now()->addSeconds($option['ttl'])->timestamp * 1000, |
357 | 357 | 'insertOnly' => Conf::INSERT_ONLY_TRUE |
358 | - ])->merge(collect($option)->except(['ttl',]))); |
|
358 | + ])->merge(collect($option)->except(['ttl', ]))); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | /** |
@@ -19,7 +19,7 @@ |
||
19 | 19 | private $namespace; |
20 | 20 | private $type; // "TOP"和"CLOUD"两种模式 |
21 | 21 | |
22 | - static $RUN_LEVEL = Conf::RUN_LEVEL_RELEASE; //设置SDK运行级别 |
|
22 | + static $RUN_LEVEL = Conf::RUN_LEVEL_RELEASE; //设置SDK运行级别 |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * 构造函数 |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | $_headers = array('Expect:'); |
336 | 336 | $date = $this->currentMilliSecond(); //得到当前的时间戳,毫秒 |
337 | 337 | array_push($_headers, "Date: {$date}"); |
338 | - $authorization = $this->_getAuthorization($uri, $date, $httpBody); //Http的Body需要加入管理鉴权 |
|
338 | + $authorization = $this->_getAuthorization($uri, $date, $httpBody); //Http的Body需要加入管理鉴权 |
|
339 | 339 | array_push($_headers, "Authorization: {$authorization}"); |
340 | 340 | array_push($_headers, "User-Agent: {$this->_getUserAgent()}"); |
341 | 341 | if (!is_null($headers) && is_array($headers)) { |
@@ -354,13 +354,13 @@ discard block |
||
354 | 354 | array_push($_headers, "Content-Type: application/x-www-form-urlencoded"); |
355 | 355 | } |
356 | 356 | array_push($_headers, "Content-Length: {$length}"); |
357 | - curl_setopt($ch, CURLOPT_HEADER, 1); //设置头部 |
|
358 | - curl_setopt($ch, CURLOPT_HTTPHEADER, $_headers); //请求头 |
|
359 | - curl_setopt($ch, CURLOPT_TIMEOUT, Conf::HTTP_TIMEOUT); //超时时长 |
|
360 | - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); //连接超时时长 |
|
357 | + curl_setopt($ch, CURLOPT_HEADER, 1); //设置头部 |
|
358 | + curl_setopt($ch, CURLOPT_HTTPHEADER, $_headers); //请求头 |
|
359 | + curl_setopt($ch, CURLOPT_TIMEOUT, Conf::HTTP_TIMEOUT); //超时时长 |
|
360 | + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); //连接超时时长 |
|
361 | 361 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //成功,只返回结果,不自动输出任何内容。如果失败返回FALSE |
362 | 362 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); |
363 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); //自定义请求 |
|
363 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); //自定义请求 |
|
364 | 364 | //设置请求方式(GET或POST等) |
365 | 365 | if ($method == 'PUT' || $method == 'POST') { |
366 | 366 | curl_setopt($ch, CURLOPT_POST, 1); |
@@ -375,10 +375,10 @@ discard block |
||
375 | 375 | } else { |
376 | 376 | //解析返回结果,并判断是否上传成功 |
377 | 377 | $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
378 | - $success = ($http_code == 200) ? true : false; //判断是否上传成功 |
|
378 | + $success = ($http_code == 200) ? true : false; //判断是否上传成功 |
|
379 | 379 | $resStr = explode("\r\n\r\n", $response); |
380 | 380 | $resBody = isset($resStr[1]) ? $resStr[1] : ''; |
381 | - $resArray = json_decode($resBody, true); //解析得到结果 |
|
381 | + $resArray = json_decode($resBody, true); //解析得到结果 |
|
382 | 382 | $result = (empty($resArray)) ? array() : $resArray; |
383 | 383 | } |
384 | 384 | } catch (Exception $e) { |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | protected function currentMilliSecond() |
451 | 451 | { |
452 | 452 | list($microSec, $stampSec) = explode(' ', microtime()); |
453 | - $tempMilli = sprintf('%03s', intval($microSec * 1000)); |
|
453 | + $tempMilli = sprintf('%03s', intval($microSec * 1000)); |
|
454 | 454 | $currentMilli = $stampSec . $tempMilli; |
455 | 455 | return $currentMilli; |
456 | 456 | } |
@@ -5,9 +5,9 @@ discard block |
||
5 | 5 | class ResourceInfo |
6 | 6 | { |
7 | 7 | /* 以下属性是资源ID所需的属性*/ |
8 | - protected $namespace; //空间名,必须 |
|
9 | - protected $dir; //路径 |
|
10 | - protected $name; //文件名信息 |
|
8 | + protected $namespace; //空间名,必须 |
|
9 | + protected $dir; //路径 |
|
10 | + protected $name; //文件名信息 |
|
11 | 11 | /* 以下属性是资源ID所需的属性*/ |
12 | 12 | /** |
13 | 13 | * ResourceOption的构造函数 |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | /**对URL中文进行编码*/ |
63 | 63 | protected function urlencode_ch($str) |
64 | 64 | { |
65 | - return preg_replace_callback('/[^\0-\127]+/', function ($match) { |
|
65 | + return preg_replace_callback('/[^\0-\127]+/', function($match) { |
|
66 | 66 | return urlencode($match[0]); |
67 | 67 | }, $str); |
68 | 68 | } |
@@ -6,15 +6,15 @@ discard block |
||
6 | 6 | class MediaEncodeOption extends MediaResOption |
7 | 7 | { |
8 | 8 | /* 以下属性是"视频转码"方法必须的属性 */ |
9 | - private $encodeTemplate; //模板名称。可以设置系统或者用户自定义模板。用户模板名称可以登录后台查看和设置,系统模板见附录系统模板列表 |
|
10 | - public $usePreset = 0; //是否使用系统模板。默认0。如果为1,则encodeTemplate必须设置系统模板名称 |
|
11 | - public $force = 0; //是否强制覆盖。默认0,如果为1,当output文件已经存在的时候会强制覆盖,否则不执行转码并结束任务 |
|
9 | + private $encodeTemplate; //模板名称。可以设置系统或者用户自定义模板。用户模板名称可以登录后台查看和设置,系统模板见附录系统模板列表 |
|
10 | + public $usePreset = 0; //是否使用系统模板。默认0。如果为1,则encodeTemplate必须设置系统模板名称 |
|
11 | + public $force = 0; //是否强制覆盖。默认0,如果为1,当output文件已经存在的时候会强制覆盖,否则不执行转码并结束任务 |
|
12 | 12 | /* 以下属性是"视频转码"方法可选的属性 */ |
13 | - private $watermark; //水印资源 |
|
14 | - private $watermarkTemplate; //用户自定义水印模板 |
|
15 | - private $notifyUrl; //通知url,任务结束之后会调用这个url |
|
16 | - private $seek; //截取音视频的开始位置 |
|
17 | - private $duration; //截取音视频的长度 |
|
13 | + private $watermark; //水印资源 |
|
14 | + private $watermarkTemplate; //用户自定义水印模板 |
|
15 | + private $notifyUrl; //通知url,任务结束之后会调用这个url |
|
16 | + private $seek; //截取音视频的开始位置 |
|
17 | + private $duration; //截取音视频的长度 |
|
18 | 18 | |
19 | 19 | /**设置转码模板。必须。模板在顽兔控制台"多媒体处理"中配置*/ |
20 | 20 | public function setEncodeTemplate($encodeTemplate) |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $httpBody .= '¬ifyUrl=' . urlencode($this->notifyUrl); |
57 | 57 | } |
58 | 58 | if (isset($this->seek)) { |
59 | - $httpBody .= '&seek=' . $this->seek; |
|
59 | + $httpBody .= '&seek=' . $this->seek; |
|
60 | 60 | } |
61 | 61 | if (isset($this->duration)) { |
62 | 62 | $httpBody .= '&duration=' . $this->duration; |
@@ -138,8 +138,8 @@ discard block |
||
138 | 138 | /**多媒体操作的输入输出资源信息。视频截图和视频转码都继承该类*/ |
139 | 139 | abstract class MediaResOption |
140 | 140 | { |
141 | - private $input; //输入的资源 |
|
142 | - private $output; //输出的资源 |
|
141 | + private $input; //输入的资源 |
|
142 | + private $output; //输出的资源 |
|
143 | 143 | /**设置输入的文件。*/ |
144 | 144 | public function setInputResource($namespace = null, $dir = null, $name = null) |
145 | 145 | { |
@@ -10,34 +10,34 @@ discard block |
||
10 | 10 | public $optionType; |
11 | 11 | |
12 | 12 | /*以下属性是上传时的可选参数。即Rest API中Http请求Body中所需的可选参数*/ |
13 | - public $dir; // 顽兔空间的图片路径(如果UploadPolicy中不指定dir属性,则生效) |
|
14 | - public $name; // 上传到服务端的文件名(如果UploadPolicy中不指定name属性,则生效) |
|
15 | - public $metaArray; // 用户自定义的文件meta信息("meta-"为参数前缀, "*"为用户用于渲染的自定义Meta信息名) |
|
16 | - public $varArray; // 用户自定义的魔法变量("var-"为参数前缀, "*"为用户用于渲染的自定义魔法变量名) |
|
17 | - private $md5; // 文件md5值(推荐提供此参数进行一致性检查) |
|
18 | - private $size; // 文件大小 |
|
19 | - private $content; // 文件内容(在http请求体Body中必须位于参数的最后一位) |
|
13 | + public $dir; // 顽兔空间的图片路径(如果UploadPolicy中不指定dir属性,则生效) |
|
14 | + public $name; // 上传到服务端的文件名(如果UploadPolicy中不指定name属性,则生效) |
|
15 | + public $metaArray; // 用户自定义的文件meta信息("meta-"为参数前缀, "*"为用户用于渲染的自定义Meta信息名) |
|
16 | + public $varArray; // 用户自定义的魔法变量("var-"为参数前缀, "*"为用户用于渲染的自定义魔法变量名) |
|
17 | + private $md5; // 文件md5值(推荐提供此参数进行一致性检查) |
|
18 | + private $size; // 文件大小 |
|
19 | + private $content; // 文件内容(在http请求体Body中必须位于参数的最后一位) |
|
20 | 20 | |
21 | 21 | /*以下属性是用户根据自己应用需求,可选的配置*/ |
22 | - public $blockSize; // 文件分片的大小。针对分片上传。 |
|
23 | - public $timeout; // 进行http连接的超时时间 |
|
24 | - public $httpReTry; // http失败自动重试。0 or 1 |
|
22 | + public $blockSize; // 文件分片的大小。针对分片上传。 |
|
23 | + public $timeout; // 进行http连接的超时时间 |
|
24 | + public $httpReTry; // http失败自动重试。0 or 1 |
|
25 | 25 | |
26 | 26 | /*以下属性是用于分片上传时的参数,仅用于分片上传。用户在调用分片上传时可以选择配置。*/ |
27 | - private $uploadId; // OSS分片上传ID(OSS用于区分上传的id) |
|
28 | - private $uniqueId; // 服务上传唯一ID(多媒体服务用于区分上传的id) |
|
29 | - private $partNumber; // 分片文件块上传成功后返回的文件块编号 |
|
30 | - private $eTag; // 分片文件块上传成功后返回的Tag标签(由md5和其他标记组成) |
|
31 | - private $array_PartNum_ETag; // 分片上传服务端返回的所有 块编号partNumber 和 标记ETag |
|
27 | + private $uploadId; // OSS分片上传ID(OSS用于区分上传的id) |
|
28 | + private $uniqueId; // 服务上传唯一ID(多媒体服务用于区分上传的id) |
|
29 | + private $partNumber; // 分片文件块上传成功后返回的文件块编号 |
|
30 | + private $eTag; // 分片文件块上传成功后返回的Tag标签(由md5和其他标记组成) |
|
31 | + private $array_PartNum_ETag; // 分片上传服务端返回的所有 块编号partNumber 和 标记ETag |
|
32 | 32 | |
33 | 33 | public function __construct() |
34 | 34 | { |
35 | 35 | $this->optionType = UpOptionType::COMMON_UPLOAD_TYPE; //默认普通上传类型 |
36 | 36 | $this->metaArray = array(); |
37 | 37 | $this->varArray = array(); |
38 | - $this->blockSize = Conf::BLOCK_DEFF_SIZE; //默认2M |
|
39 | - $this->timeout = Conf::HTTP_TIMEOUT; //默认超时30s |
|
40 | - $this->httpReTry = Conf::HTTP_RETRY; //默认重试 |
|
38 | + $this->blockSize = Conf::BLOCK_DEFF_SIZE; //默认2M |
|
39 | + $this->timeout = Conf::HTTP_TIMEOUT; //默认超时30s |
|
40 | + $this->httpReTry = Conf::HTTP_RETRY; //默认重试 |
|
41 | 41 | $this->array_PartNum_ETag = array(); |
42 | 42 | } |
43 | 43 | /**得到上传时http请求体所需的参数*/ |
@@ -174,9 +174,9 @@ discard block |
||
174 | 174 | class UpOptionType |
175 | 175 | { |
176 | 176 | //下面的常量用于标识UploadOption对象适用的类型 |
177 | - const COMMON_UPLOAD_TYPE = 0; //普通上传时的UploadOption类型 |
|
178 | - const BLOCK_INIT_UPLOAD = 1; //分片初始化时的UploadOption类型 |
|
179 | - const BLOCK_RUN_UPLOAD = 2; //分片上传过程中的UploadOption类型 |
|
180 | - const BLOCK_COMPLETE_UPLOAD = 3; //分片上传完成时的UploadOption类型 |
|
181 | - const BLOCK_CANCEL_UPLOAD = 4; //分片上传取消时的UploadOption类型 |
|
177 | + const COMMON_UPLOAD_TYPE = 0; //普通上传时的UploadOption类型 |
|
178 | + const BLOCK_INIT_UPLOAD = 1; //分片初始化时的UploadOption类型 |
|
179 | + const BLOCK_RUN_UPLOAD = 2; //分片上传过程中的UploadOption类型 |
|
180 | + const BLOCK_COMPLETE_UPLOAD = 3; //分片上传完成时的UploadOption类型 |
|
181 | + const BLOCK_CANCEL_UPLOAD = 4; //分片上传取消时的UploadOption类型 |
|
182 | 182 | } |
@@ -6,24 +6,24 @@ |
||
6 | 6 | class UploadPolicy |
7 | 7 | { |
8 | 8 | /*如下属性是必须的[The following attributes are required]*/ |
9 | - public $namespace; // 多媒体服务的空间名[media namespace name] |
|
10 | - public $bucket; // OSS的空间名[media bucket name] |
|
11 | - public $insertOnly; // 是否可覆盖[upload mode. it's not allowd uploading the same name files] |
|
12 | - public $expiration; // 过期时间[expiration time, unix time, in milliseconds] |
|
9 | + public $namespace; // 多媒体服务的空间名[media namespace name] |
|
10 | + public $bucket; // OSS的空间名[media bucket name] |
|
11 | + public $insertOnly; // 是否可覆盖[upload mode. it's not allowd uploading the same name files] |
|
12 | + public $expiration; // 过期时间[expiration time, unix time, in milliseconds] |
|
13 | 13 | |
14 | 14 | /*如下属性是可选的[The following attributes are optional]*/ |
15 | - public $detectMime = Conf::DETECT_MIME_TRUE; // 是否进行类型检测[is auto detecte media file mime type, default is true] |
|
16 | - public $dir; // 路径[media file dir, magic vars and custom vars are supported] |
|
17 | - public $name; // 上传到服务端的文件名[media file name, magic vars and custom vars are supported] |
|
18 | - public $sizeLimit; // 文件大小限制[upload size limited, in bytes] |
|
19 | - public $mimeLimit; // 文件类型限制[upload mime type limited] |
|
20 | - public $callbackUrl; // 回调URL [callback urls, ip address is recommended] |
|
21 | - public $callbackHost; // 回调时Host [callback host] |
|
22 | - public $callbackBody; // 回调时Body [callback body, magic vars and custom vars are supported] |
|
23 | - public $callbackBodyType; // 回调时Body类型 [callback body type, default is 'application/x-www-form-urlencoded; charset=utf-8'] |
|
24 | - public $returnUrl; // 上传完成之后,303跳转的Url [return url, when return code is 303] |
|
25 | - public $returnBody; // 上传完成返回体 [return body, magic vars and custom vars are supported] |
|
26 | - public $mediaEncode; // 上传音视频时,可以指定转码策略[media encode policy after upload task has been completed. it's json string] |
|
15 | + public $detectMime = Conf::DETECT_MIME_TRUE; // 是否进行类型检测[is auto detecte media file mime type, default is true] |
|
16 | + public $dir; // 路径[media file dir, magic vars and custom vars are supported] |
|
17 | + public $name; // 上传到服务端的文件名[media file name, magic vars and custom vars are supported] |
|
18 | + public $sizeLimit; // 文件大小限制[upload size limited, in bytes] |
|
19 | + public $mimeLimit; // 文件类型限制[upload mime type limited] |
|
20 | + public $callbackUrl; // 回调URL [callback urls, ip address is recommended] |
|
21 | + public $callbackHost; // 回调时Host [callback host] |
|
22 | + public $callbackBody; // 回调时Body [callback body, magic vars and custom vars are supported] |
|
23 | + public $callbackBodyType; // 回调时Body类型 [callback body type, default is 'application/x-www-form-urlencoded; charset=utf-8'] |
|
24 | + public $returnUrl; // 上传完成之后,303跳转的Url [return url, when return code is 303] |
|
25 | + public $returnBody; // 上传完成返回体 [return body, magic vars and custom vars are supported] |
|
26 | + public $mediaEncode; // 上传音视频时,可以指定转码策略[media encode policy after upload task has been completed. it's json string] |
|
27 | 27 | |
28 | 28 | public function __construct($option) |
29 | 29 | { |
@@ -5,8 +5,8 @@ |
||
5 | 5 | final class ManageOption extends ResourceInfo |
6 | 6 | { |
7 | 7 | /*以下属性是”获取资源列表"方法所需的属性。即listFiles()、listDirs()方法中的参数 */ |
8 | - private $currentPage; //当前页号 |
|
9 | - private $pageSize; //每页的大小 |
|
8 | + private $currentPage; //当前页号 |
|
9 | + private $pageSize; //每页的大小 |
|
10 | 10 | /* 以下属性是"扫描黄图和广告图"方法所需的属性。即scanPorn()和scanAdvertising方法中的参数 */ |
11 | 11 | private $filesArray; |
12 | 12 | private $urlsArray; |