@@ -137,10 +137,12 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public function existsFolder($namespace, $dir) |
139 | 139 | { |
140 | - if (empty($namespace) || empty($dir)) |
|
141 | - return $this->_errorResponse("InvalidArgument", "namespace or dir is empty"); |
|
142 | - if (strpos($dir, '/') !== 0) |
|
143 | - $dir = '/' . $dir; |
|
140 | + if (empty($namespace) || empty($dir)) { |
|
141 | + return $this->_errorResponse("InvalidArgument", "namespace or dir is empty"); |
|
142 | + } |
|
143 | + if (strpos($dir, '/') !== 0) { |
|
144 | + $dir = '/' . $dir; |
|
145 | + } |
|
144 | 146 | $resourceInfo = new ResourceInfo($namespace, $dir); |
145 | 147 | $resourceId = $resourceInfo->buildResourceId(); //得到资源ID |
146 | 148 | $uri = '/' . Conf::MANAGE_API_VERSION . '/folders/' . $resourceId . '/exist'; |
@@ -155,10 +157,12 @@ discard block |
||
155 | 157 | */ |
156 | 158 | public function createDir($namespace, $dir) |
157 | 159 | { |
158 | - if (empty($namespace) || empty($dir)) |
|
159 | - return $this->_errorResponse("InvalidArgument", "namespace or dir is empty"); |
|
160 | - if (strpos($dir, '/') !== 0) |
|
161 | - $dir = '/' . $dir; |
|
160 | + if (empty($namespace) || empty($dir)) { |
|
161 | + return $this->_errorResponse("InvalidArgument", "namespace or dir is empty"); |
|
162 | + } |
|
163 | + if (strpos($dir, '/') !== 0) { |
|
164 | + $dir = '/' . $dir; |
|
165 | + } |
|
162 | 166 | $resourceInfo = new ResourceInfo($namespace, $dir); |
163 | 167 | $resourceId = $resourceInfo->buildResourceId(); //得到资源ID |
164 | 168 | $uri = '/' . Conf::MANAGE_API_VERSION . '/folders/' . $resourceId; |
@@ -197,10 +201,12 @@ discard block |
||
197 | 201 | */ |
198 | 202 | public function deleteDir($namespace, $dir) |
199 | 203 | { |
200 | - if (empty($namespace) || empty($dir)) |
|
201 | - return $this->_errorResponse("InvalidArgument", "namespace or dir is empty"); |
|
202 | - if (strpos($dir, '/') !== 0) |
|
203 | - $dir = '/' . $dir; |
|
204 | + if (empty($namespace) || empty($dir)) { |
|
205 | + return $this->_errorResponse("InvalidArgument", "namespace or dir is empty"); |
|
206 | + } |
|
207 | + if (strpos($dir, '/') !== 0) { |
|
208 | + $dir = '/' . $dir; |
|
209 | + } |
|
204 | 210 | $resourceInfo = new ResourceInfo($namespace, $dir); |
205 | 211 | $resourceId = $resourceInfo->buildResourceId(); //得到资源ID |
206 | 212 | $uri = '/' . Conf::MANAGE_API_VERSION . '/folders/' . $resourceId; |
@@ -260,8 +266,9 @@ discard block |
||
260 | 266 | */ |
261 | 267 | public function mediaEncodeQuery($taskId) |
262 | 268 | { |
263 | - if (empty($taskId)) |
|
264 | - return $this->_errorResponse("InvalidArgument", "taskId is empty"); |
|
269 | + if (empty($taskId)) { |
|
270 | + return $this->_errorResponse("InvalidArgument", "taskId is empty"); |
|
271 | + } |
|
265 | 272 | $uri = '/' . Conf::MEDIA_ENCODE_VERSION . '/mediaEncodeResult/' . $taskId; |
266 | 273 | return $this->_send_request('GET', $uri); |
267 | 274 | } |
@@ -287,8 +294,9 @@ discard block |
||
287 | 294 | */ |
288 | 295 | public function vSnapshotQuery($taskId) |
289 | 296 | { |
290 | - if (empty($taskId)) |
|
291 | - return $this->_errorResponse("InvalidArgument", "taskId is empty"); |
|
297 | + if (empty($taskId)) { |
|
298 | + return $this->_errorResponse("InvalidArgument", "taskId is empty"); |
|
299 | + } |
|
292 | 300 | $uri = '/' . Conf::MANAGE_API_VERSION . '/snapshotResult/' . $taskId; |
293 | 301 | return $this->_send_request('GET', $uri); |
294 | 302 | } |
@@ -21,12 +21,17 @@ discard block |
||
21 | 21 | /**检测多媒体转码选项是否合法。如果合法,则返回http请求体<p> 返回格式{$isValid, $message, $httpBody}*/ |
22 | 22 | public function checkOptionParameters() { |
23 | 23 | list ( $valid, $msg ) = parent::checkOptionParameters(); //检测输入输出资源是否合法 |
24 | - if ( !$valid ) |
|
25 | - return array ( $valid, $msg, null ); |
|
26 | - if ( empty($this->encodeTemplate) ) |
|
27 | - return array ( false, "encodeTemplate is empty.", null ); // 判断是否设置输入输出文件,或者转码模板 |
|
28 | - if( ($this->usePreset!=0 && $this->usePreset!=1) || ($this->force!=0 && $this->force!=1) ) |
|
29 | - return array ( false, "parameters 'usePreset' or 'force' is invalid.", null ); // 判断usePreset和force参数是否为0或1 |
|
24 | + if ( !$valid ) { |
|
25 | + return array ( $valid, $msg, null ); |
|
26 | + } |
|
27 | + if ( empty($this->encodeTemplate) ) { |
|
28 | + return array ( false, "encodeTemplate is empty.", null ); |
|
29 | + } |
|
30 | + // 判断是否设置输入输出文件,或者转码模板 |
|
31 | + if( ($this->usePreset!=0 && $this->usePreset!=1) || ($this->force!=0 && $this->force!=1) ) { |
|
32 | + return array ( false, "parameters 'usePreset' or 'force' is invalid.", null ); |
|
33 | + } |
|
34 | + // 判断usePreset和force参数是否为0或1 |
|
30 | 35 | return $this->getOptionsHttpBody(); //返回http请求体 |
31 | 36 | } |
32 | 37 | /**构建多媒体转码所需的http请求体*/ |
@@ -38,16 +43,21 @@ discard block |
||
38 | 43 | $httpBody .= '&usePreset=' . $this->usePreset; |
39 | 44 | $httpBody .= '&force=' . $this->force; |
40 | 45 | // 可选的参数 |
41 | - if (isset ( $this->watermark )) |
|
42 | - $httpBody .= '&watermark=' . $this->watermark->buildResourceId (); |
|
43 | - if (isset ( $this->watermarkTemplate )) |
|
44 | - $httpBody .= '&watermarkTemplate=' . urlencode($this->watermarkTemplate); |
|
45 | - if (isset ( $this->notifyUrl )) |
|
46 | - $httpBody .= '¬ifyUrl=' . urlencode($this->notifyUrl); |
|
47 | - if (isset ( $this->seek )) |
|
48 | - $httpBody .= '&seek=' . $this->seek; |
|
49 | - if (isset ( $this->duration )) |
|
50 | - $httpBody .= '&duration=' . $this->duration; |
|
46 | + if (isset ( $this->watermark )) { |
|
47 | + $httpBody .= '&watermark=' . $this->watermark->buildResourceId (); |
|
48 | + } |
|
49 | + if (isset ( $this->watermarkTemplate )) { |
|
50 | + $httpBody .= '&watermarkTemplate=' . urlencode($this->watermarkTemplate); |
|
51 | + } |
|
52 | + if (isset ( $this->notifyUrl )) { |
|
53 | + $httpBody .= '¬ifyUrl=' . urlencode($this->notifyUrl); |
|
54 | + } |
|
55 | + if (isset ( $this->seek )) { |
|
56 | + $httpBody .= '&seek=' . $this->seek; |
|
57 | + } |
|
58 | + if (isset ( $this->duration )) { |
|
59 | + $httpBody .= '&duration=' . $this->duration; |
|
60 | + } |
|
51 | 61 | return array ( true, "valid", $httpBody ); //视频转码参数合法,返回http请求体 |
52 | 62 | } |
53 | 63 | /*######################以下是可选的参数set方法#######################*/ |
@@ -81,10 +91,13 @@ discard block |
||
81 | 91 | /**检测视频截图参数是否合法。如果合法,则返回http请求体<p> 返回格式{$isValid, $message, $httpBody}*/ |
82 | 92 | public function checkOptionParameters() { |
83 | 93 | list ( $valid, $msg ) = parent::checkOptionParameters(); //检测输入输出资源是否合法 |
84 | - if ( !$valid ) |
|
85 | - return array ( $valid, $msg, null ); |
|
86 | - if ( empty($this->time) || !is_int($this->time) || $this->time<0) |
|
87 | - return array ( false, "time is empty or invalid.", null ); // 是否设置时间,且时间是否合法 |
|
94 | + if ( !$valid ) { |
|
95 | + return array ( $valid, $msg, null ); |
|
96 | + } |
|
97 | + if ( empty($this->time) || !is_int($this->time) || $this->time<0) { |
|
98 | + return array ( false, "time is empty or invalid.", null ); |
|
99 | + } |
|
100 | + // 是否设置时间,且时间是否合法 |
|
88 | 101 | return $this->getOptionsHttpBody(); //返回http请求体 |
89 | 102 | } |
90 | 103 | /**构建多媒体转码所需的http请求体*/ |
@@ -94,8 +107,9 @@ discard block |
||
94 | 107 | $httpBody .= '&output=' . $this->getOutputResId(); |
95 | 108 | $httpBody .= '&time=' . $this->time; |
96 | 109 | // 可选的参数 |
97 | - if (isset ( $this->notifyUrl )) |
|
98 | - $httpBody .= '¬ifyUrl=' . urlencode($this->notifyUrl) ; |
|
110 | + if (isset ( $this->notifyUrl )) { |
|
111 | + $httpBody .= '¬ifyUrl=' . urlencode($this->notifyUrl) ; |
|
112 | + } |
|
99 | 113 | return array ( true, "valid", $httpBody ); //视频转码参数合法,返回http请求体 |
100 | 114 | } |
101 | 115 | |
@@ -122,14 +136,18 @@ discard block |
||
122 | 136 | } |
123 | 137 | /**检测参数选项是否合法*/ |
124 | 138 | public function checkOptionParameters() { |
125 | - if ( empty($this->input) || empty($this->output) ) |
|
126 | - return array ( false, "input or output resources is empty." ); // 判断是否设置输入输出文件,或者转码模板 |
|
139 | + if ( empty($this->input) || empty($this->output) ) { |
|
140 | + return array ( false, "input or output resources is empty." ); |
|
141 | + } |
|
142 | + // 判断是否设置输入输出文件,或者转码模板 |
|
127 | 143 | list ( $valid, $msg ) = $this->input->checkResourceInfo(true,true);//检测输入的资源信息是否合法 |
128 | - if(!$valid) |
|
129 | - return array ( $valid, $msg ); |
|
144 | + if(!$valid) { |
|
145 | + return array ( $valid, $msg ); |
|
146 | + } |
|
130 | 147 | list ( $valid, $msg ) = $this->output->checkResourceInfo(true,true);//检测输入的资源信息是否合法 |
131 | - if(!$valid) |
|
132 | - return array ( $valid, $msg ); |
|
148 | + if(!$valid) { |
|
149 | + return array ( $valid, $msg ); |
|
150 | + } |
|
133 | 151 | return array( true, null); |
134 | 152 | } |
135 | 153 | public function getInputResId() { |
@@ -60,10 +60,12 @@ |
||
60 | 60 | private function getParas_Common_BlockInit() |
61 | 61 | { |
62 | 62 | $paraArray = array(); |
63 | - if (isset($this->dir)) |
|
64 | - $paraArray['dir'] = $this->dir; |
|
65 | - if (isset($this->name)) |
|
66 | - $paraArray['name'] = $this->name; |
|
63 | + if (isset($this->dir)) { |
|
64 | + $paraArray['dir'] = $this->dir; |
|
65 | + } |
|
66 | + if (isset($this->name)) { |
|
67 | + $paraArray['name'] = $this->name; |
|
68 | + } |
|
67 | 69 | $paraArray['md5'] = md5($this->content); // 计算文件md5 |
68 | 70 | $paraArray['size'] = strlen($this->content); // 计算文件大小 |
69 | 71 | $paraArray['content'] = $this->content; |
@@ -5,47 +5,47 @@ |
||
5 | 5 | |
6 | 6 | class UploadPolicy |
7 | 7 | { |
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] |
|
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] |
|
13 | 13 | |
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] |
|
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] |
|
27 | 27 | |
28 | - public function __construct($option) |
|
29 | - { |
|
30 | - if (!isset($option['expiration']) || !$option['expiration']) { |
|
31 | - $option['expiration'] = -1; |
|
32 | - } |
|
28 | + public function __construct($option) |
|
29 | + { |
|
30 | + if (!isset($option['expiration']) || !$option['expiration']) { |
|
31 | + $option['expiration'] = -1; |
|
32 | + } |
|
33 | 33 | |
34 | - foreach ($option as $attribute => $value) { |
|
35 | - $this->{$attribute} = $value; |
|
36 | - } |
|
37 | - } |
|
34 | + foreach ($option as $attribute => $value) { |
|
35 | + $this->{$attribute} = $value; |
|
36 | + } |
|
37 | + } |
|
38 | 38 | |
39 | - public function toArray() |
|
40 | - { |
|
41 | - return (array) $this; |
|
42 | - $array = []; |
|
43 | - foreach ($this as $attribute => $value) { |
|
44 | - if ($value !== null) { |
|
45 | - $array[$attribute] = $value; |
|
46 | - } |
|
47 | - } |
|
39 | + public function toArray() |
|
40 | + { |
|
41 | + return (array) $this; |
|
42 | + $array = []; |
|
43 | + foreach ($this as $attribute => $value) { |
|
44 | + if ($value !== null) { |
|
45 | + $array[$attribute] = $value; |
|
46 | + } |
|
47 | + } |
|
48 | 48 | |
49 | - return $array; |
|
50 | - } |
|
49 | + return $array; |
|
50 | + } |
|
51 | 51 | } |
@@ -22,10 +22,14 @@ discard block |
||
22 | 22 | * 返回格式{$isValid, $message}*/ |
23 | 23 | public function checkResourceInfo($dirState = false, $nameState = false) |
24 | 24 | { |
25 | - if (empty($this->namespace)) |
|
26 | - return array(false, "namespace is empty.[{$this->toString()}]"); // 判断是否设置空间名 |
|
27 | - else |
|
28 | - return $this->checkFileInfo($dirState, $nameState); // 判断dir和name的合法性 |
|
25 | + if (empty($this->namespace)) { |
|
26 | + return array(false, "namespace is empty.[{$this->toString()}]"); |
|
27 | + } |
|
28 | + // 判断是否设置空间名 |
|
29 | + else { |
|
30 | + return $this->checkFileInfo($dirState, $nameState); |
|
31 | + } |
|
32 | + // 判断dir和name的合法性 |
|
29 | 33 | } |
30 | 34 | /**检测文件信息是否合法。$dirState表示是否检测dir,$nameState表示是否检测filename<p> |
31 | 35 | * 返回格式{$isValid, $message}*/ |
@@ -35,10 +39,14 @@ discard block |
||
35 | 39 | return array(false, "file's name is empty.[{$this->toString()}]"); // 1:若需要进行文件名name检测,则判断文件名是否为空 |
36 | 40 | } |
37 | 41 | if ($dirState) { |
38 | - if (empty($this->dir)) |
|
39 | - $this->dir = '/'; // 2:判断路径是否为空,若为空,则默认为根目录'/' |
|
40 | - else if (strpos($this->dir, '/') !== 0) |
|
41 | - $this->dir = '/' . $this->dir; // 3:判断路径是否以'/'开头,若不是,则添加'/' |
|
42 | + if (empty($this->dir)) { |
|
43 | + $this->dir = '/'; |
|
44 | + } |
|
45 | + // 2:判断路径是否为空,若为空,则默认为根目录'/' |
|
46 | + else if (strpos($this->dir, '/') !== 0) { |
|
47 | + $this->dir = '/' . $this->dir; |
|
48 | + } |
|
49 | + // 3:判断路径是否以'/'开头,若不是,则添加'/' |
|
42 | 50 | } |
43 | 51 | return array(true, null); |
44 | 52 | } |
@@ -46,12 +54,15 @@ discard block |
||
46 | 54 | public function buildResourceId() |
47 | 55 | { |
48 | 56 | $jsonData = array(); |
49 | - if (!empty($this->namespace)) |
|
50 | - array_push($jsonData, urldecode($this->namespace)); |
|
51 | - if (!empty($this->dir)) |
|
52 | - array_push($jsonData, urldecode($this->dir)); |
|
53 | - if (!empty($this->name)) |
|
54 | - array_push($jsonData, urldecode($this->name)); |
|
57 | + if (!empty($this->namespace)) { |
|
58 | + array_push($jsonData, urldecode($this->namespace)); |
|
59 | + } |
|
60 | + if (!empty($this->dir)) { |
|
61 | + array_push($jsonData, urldecode($this->dir)); |
|
62 | + } |
|
63 | + if (!empty($this->name)) { |
|
64 | + array_push($jsonData, urldecode($this->name)); |
|
65 | + } |
|
55 | 66 | return EncodeUtils::encodeWithURLSafeBase64(json_encode($jsonData, true)); |
56 | 67 | } |
57 | 68 | /**对URL中文进行编码*/ |
@@ -3,39 +3,39 @@ |
||
3 | 3 | |
4 | 4 | class Conf |
5 | 5 | { |
6 | - const CHARSET = "UTF-8"; |
|
7 | - const SDK_VERSION = '2.0.3'; |
|
6 | + const CHARSET = "UTF-8"; |
|
7 | + const SDK_VERSION = '2.0.3'; |
|
8 | 8 | |
9 | - const UPLOAD_HOST_MEDIA = "https://upload.media.aliyun.com"; //文件上传的地址 |
|
10 | - const MANAGE_HOST_MEDIA = "https://rs.media.aliyun.com"; //服务管理的地址 |
|
11 | - const MANAGE_API_VERSION = "3.0"; //资源管理接口版本 |
|
12 | - const SCAN_PORN_VERSION = "3.1"; //黄图扫描接口版本 |
|
13 | - const MEDIA_ENCODE_VERSION = "3.0"; //媒体转码接口版本 |
|
9 | + const UPLOAD_HOST_MEDIA = "https://upload.media.aliyun.com"; //文件上传的地址 |
|
10 | + const MANAGE_HOST_MEDIA = "https://rs.media.aliyun.com"; //服务管理的地址 |
|
11 | + const MANAGE_API_VERSION = "3.0"; //资源管理接口版本 |
|
12 | + const SCAN_PORN_VERSION = "3.1"; //黄图扫描接口版本 |
|
13 | + const MEDIA_ENCODE_VERSION = "3.0"; //媒体转码接口版本 |
|
14 | 14 | |
15 | - const UPLOAD_API_UPLOAD = "/api/proxy/upload"; |
|
16 | - const UPLOAD_API_BLOCK_INIT = "/api/proxy/blockInit"; |
|
17 | - const UPLOAD_API_BLOCK_UPLOAD = "/api/proxy/blockUpload"; |
|
18 | - const UPLOAD_API_BLOCK_COMPLETE = "/api/proxy/blockComplete"; |
|
19 | - const UPLOAD_API_BLOCK_CANCEL = "/api/proxy/blockCancel"; |
|
15 | + const UPLOAD_API_UPLOAD = "/api/proxy/upload"; |
|
16 | + const UPLOAD_API_BLOCK_INIT = "/api/proxy/blockInit"; |
|
17 | + const UPLOAD_API_BLOCK_UPLOAD = "/api/proxy/blockUpload"; |
|
18 | + const UPLOAD_API_BLOCK_COMPLETE = "/api/proxy/blockComplete"; |
|
19 | + const UPLOAD_API_BLOCK_CANCEL = "/api/proxy/blockCancel"; |
|
20 | 20 | |
21 | - const TYPE_TOP = "TOP"; |
|
22 | - const TYPE_CLOUD = "CLOUD"; |
|
21 | + const TYPE_TOP = "TOP"; |
|
22 | + const TYPE_CLOUD = "CLOUD"; |
|
23 | 23 | |
24 | - const DETECT_MIME_TRUE = 1; //检测MimeType |
|
25 | - const DETECT_MIME_NONE = 0; //不检测MimeType |
|
26 | - const INSERT_ONLY_TRUE = 1; //文件上传不可覆盖 |
|
27 | - const INSERT_ONLY_NONE = 0; //文件上传可覆盖 |
|
24 | + const DETECT_MIME_TRUE = 1; //检测MimeType |
|
25 | + const DETECT_MIME_NONE = 0; //不检测MimeType |
|
26 | + const INSERT_ONLY_TRUE = 1; //文件上传不可覆盖 |
|
27 | + const INSERT_ONLY_NONE = 0; //文件上传可覆盖 |
|
28 | 28 | |
29 | - const MIN_OBJ_SIZE = 102400; //1024*100; |
|
30 | - const HTTP_TIMEOUT = 30; //http的超时时间:30s |
|
31 | - const HTTP_RETRY = 1; //http失败后重试:1 |
|
29 | + const MIN_OBJ_SIZE = 102400; //1024*100; |
|
30 | + const HTTP_TIMEOUT = 30; //http的超时时间:30s |
|
31 | + const HTTP_RETRY = 1; //http失败后重试:1 |
|
32 | 32 | |
33 | - const BLOCK_MIN_SIZE = 102400; //文件分片最小值:1024*100; 100K |
|
34 | - const BLOCK_DEFF_SIZE = 2097152; //文件分片默认值:1024*1024*2; 2M |
|
35 | - const BLOCK_MAX_SIZE = 10485760; //文件分片最大值:1024*1024*10; 10M |
|
33 | + const BLOCK_MIN_SIZE = 102400; //文件分片最小值:1024*100; 100K |
|
34 | + const BLOCK_DEFF_SIZE = 2097152; //文件分片默认值:1024*1024*2; 2M |
|
35 | + const BLOCK_MAX_SIZE = 10485760; //文件分片最大值:1024*1024*10; 10M |
|
36 | 36 | |
37 | - const CURL_ERR_LOG = "curl_error.log"; //curl请求时的错误日志信息 |
|
37 | + const CURL_ERR_LOG = "curl_error.log"; //curl请求时的错误日志信息 |
|
38 | 38 | |
39 | - const RUN_LEVEL_RELEASE = 1; //release级别 |
|
40 | - const RUN_LEVEL_DEBUG = 2; //debug级别 |
|
39 | + const RUN_LEVEL_RELEASE = 1; //release级别 |
|
40 | + const RUN_LEVEL_DEBUG = 2; //debug级别 |
|
41 | 41 | } |
@@ -10,22 +10,22 @@ |
||
10 | 10 | |
11 | 11 | class WantuFileServiceProvider extends ServiceProvider |
12 | 12 | { |
13 | - public function boot() |
|
14 | - { |
|
15 | - app('filesystem')->extend('wantu', function ($app, $config) { |
|
16 | - $adapter = new WantuFileAdapter( |
|
17 | - $config['access_key'], |
|
18 | - $config['secret_key'], |
|
19 | - $config['namespace'], |
|
20 | - $config['domain'] |
|
21 | - ); |
|
22 | - $flysystem = new Filesystem($adapter, new Config(['disable_asserts' => true])); |
|
23 | - // $flysystem->addPlugin(new FetchFile()); |
|
24 | - $flysystem->addPlugin(new UploadToken()); |
|
25 | - $flysystem->addPlugin(new GetUrl()); |
|
26 | - // $flysystem->addPlugin(new PrivateDownloadUrl()); |
|
27 | - // $flysystem->addPlugin(new RefreshFile()); |
|
28 | - return $flysystem; |
|
29 | - }); |
|
30 | - } |
|
13 | + public function boot() |
|
14 | + { |
|
15 | + app('filesystem')->extend('wantu', function ($app, $config) { |
|
16 | + $adapter = new WantuFileAdapter( |
|
17 | + $config['access_key'], |
|
18 | + $config['secret_key'], |
|
19 | + $config['namespace'], |
|
20 | + $config['domain'] |
|
21 | + ); |
|
22 | + $flysystem = new Filesystem($adapter, new Config(['disable_asserts' => true])); |
|
23 | + // $flysystem->addPlugin(new FetchFile()); |
|
24 | + $flysystem->addPlugin(new UploadToken()); |
|
25 | + $flysystem->addPlugin(new GetUrl()); |
|
26 | + // $flysystem->addPlugin(new PrivateDownloadUrl()); |
|
27 | + // $flysystem->addPlugin(new RefreshFile()); |
|
28 | + return $flysystem; |
|
29 | + }); |
|
30 | + } |
|
31 | 31 | } |
@@ -5,13 +5,13 @@ |
||
5 | 5 | |
6 | 6 | class UploadToken extends AbstractPlugin |
7 | 7 | { |
8 | - public function getMethod() |
|
9 | - { |
|
10 | - return 'getUploadToken'; |
|
11 | - } |
|
8 | + public function getMethod() |
|
9 | + { |
|
10 | + return 'getUploadToken'; |
|
11 | + } |
|
12 | 12 | |
13 | - public function handle($option = null) |
|
14 | - { |
|
15 | - return $this->filesystem->getAdapter()->getUploadToken($option); |
|
16 | - } |
|
13 | + public function handle($option = null) |
|
14 | + { |
|
15 | + return $this->filesystem->getAdapter()->getUploadToken($option); |
|
16 | + } |
|
17 | 17 | } |
@@ -5,12 +5,12 @@ |
||
5 | 5 | |
6 | 6 | class GetUrl extends AbstractPlugin |
7 | 7 | { |
8 | - public function getMethod() |
|
9 | - { |
|
10 | - return 'getUrl'; |
|
11 | - } |
|
12 | - public function handle($path) |
|
13 | - { |
|
14 | - return $this->filesystem->getAdapter()->getUrl($path); |
|
15 | - } |
|
8 | + public function getMethod() |
|
9 | + { |
|
10 | + return 'getUrl'; |
|
11 | + } |
|
12 | + public function handle($path) |
|
13 | + { |
|
14 | + return $this->filesystem->getAdapter()->getUrl($path); |
|
15 | + } |
|
16 | 16 | } |